Mercurial > libavcodec.hg
comparison rv34.c @ 9903:305536ce781f libavcodec
RV3/4 intra types array causes alignment issues (at least on ARM5), thus change
its stride and offset to always have align 4.
author | kostya |
---|---|
date | Wed, 01 Jul 2009 15:08:02 +0000 |
parents | 976a7ad342af |
children | d0f2f4e4436c |
comparison
equal
deleted
inserted
replaced
9902:9bdf9fe9018c | 9903:305536ce781f |
---|---|
982 avail[idx] = 1; | 982 avail[idx] = 1; |
983 if(cbp & 1) | 983 if(cbp & 1) |
984 rv34_add_4x4_block(Y, s->linesize, s->block[(i>>1)+(j&2)], (i&1)*4+(j&1)*32); | 984 rv34_add_4x4_block(Y, s->linesize, s->block[(i>>1)+(j&2)], (i&1)*4+(j&1)*32); |
985 } | 985 } |
986 Y += s->linesize * 4 - 4*4; | 986 Y += s->linesize * 4 - 4*4; |
987 intra_types += s->b4_stride; | 987 intra_types += r->intra_types_stride; |
988 } | 988 } |
989 intra_types -= s->b4_stride * 4; | 989 intra_types -= r->intra_types_stride * 4; |
990 fill_rectangle(r->avail_cache + 5, 2, 2, 4, 0, 4); | 990 fill_rectangle(r->avail_cache + 5, 2, 2, 4, 0, 4); |
991 for(j = 0; j < 2; j++){ | 991 for(j = 0; j < 2; j++){ |
992 idx = 5 + j*4; | 992 idx = 5 + j*4; |
993 for(i = 0; i < 2; i++, cbp >>= 1, idx++){ | 993 for(i = 0; i < 2; i++, cbp >>= 1, idx++){ |
994 rv34_pred_4x4_block(r, U + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*s->b4_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]); | 994 rv34_pred_4x4_block(r, U + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*r->intra_types_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]); |
995 rv34_pred_4x4_block(r, V + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*s->b4_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]); | 995 rv34_pred_4x4_block(r, V + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*r->intra_types_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]); |
996 r->avail_cache[idx] = 1; | 996 r->avail_cache[idx] = 1; |
997 if(cbp & 0x01) | 997 if(cbp & 0x01) |
998 rv34_add_4x4_block(U + i*4 + j*4*s->uvlinesize, s->uvlinesize, s->block[4], i*4+j*32); | 998 rv34_add_4x4_block(U + i*4 + j*4*s->uvlinesize, s->uvlinesize, s->block[4], i*4+j*32); |
999 if(cbp & 0x10) | 999 if(cbp & 0x10) |
1000 rv34_add_4x4_block(V + i*4 + j*4*s->uvlinesize, s->uvlinesize, s->block[5], i*4+j*32); | 1000 rv34_add_4x4_block(V + i*4 + j*4*s->uvlinesize, s->uvlinesize, s->block[5], i*4+j*32); |
1054 r->mb_type[mb_pos] = RV34_MB_B_DIRECT; | 1054 r->mb_type[mb_pos] = RV34_MB_B_DIRECT; |
1055 } | 1055 } |
1056 r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]); | 1056 r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->mb_type[mb_pos]); |
1057 rv34_decode_mv(r, r->block_type); | 1057 rv34_decode_mv(r, r->block_type); |
1058 if(r->block_type == RV34_MB_SKIP){ | 1058 if(r->block_type == RV34_MB_SKIP){ |
1059 fill_rectangle(intra_types, 4, 4, s->b4_stride, 0, sizeof(intra_types[0])); | 1059 fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0])); |
1060 return 0; | 1060 return 0; |
1061 } | 1061 } |
1062 r->chroma_vlc = 1; | 1062 r->chroma_vlc = 1; |
1063 r->luma_vlc = 0; | 1063 r->luma_vlc = 0; |
1064 } | 1064 } |
1065 if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){ | 1065 if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){ |
1066 if(r->is16){ | 1066 if(r->is16){ |
1067 t = get_bits(gb, 2); | 1067 t = get_bits(gb, 2); |
1068 fill_rectangle(intra_types, 4, 4, s->b4_stride, t, sizeof(intra_types[0])); | 1068 fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); |
1069 r->luma_vlc = 2; | 1069 r->luma_vlc = 2; |
1070 }else{ | 1070 }else{ |
1071 if(r->decode_intra_types(r, gb, intra_types) < 0) | 1071 if(r->decode_intra_types(r, gb, intra_types) < 0) |
1072 return -1; | 1072 return -1; |
1073 r->luma_vlc = 1; | 1073 r->luma_vlc = 1; |
1074 } | 1074 } |
1075 r->chroma_vlc = 0; | 1075 r->chroma_vlc = 0; |
1076 r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); | 1076 r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); |
1077 }else{ | 1077 }else{ |
1078 for(i = 0; i < 16; i++) | 1078 for(i = 0; i < 16; i++) |
1079 intra_types[(i & 3) + (i>>2) * s->b4_stride] = 0; | 1079 intra_types[(i & 3) + (i>>2) * r->intra_types_stride] = 0; |
1080 r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); | 1080 r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); |
1081 if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){ | 1081 if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){ |
1082 r->is16 = 1; | 1082 r->is16 = 1; |
1083 r->chroma_vlc = 1; | 1083 r->chroma_vlc = 1; |
1084 r->luma_vlc = 2; | 1084 r->luma_vlc = 2; |
1280 MPV_common_end(s); | 1280 MPV_common_end(s); |
1281 s->width = r->si.width; | 1281 s->width = r->si.width; |
1282 s->height = r->si.height; | 1282 s->height = r->si.height; |
1283 if(MPV_common_init(s) < 0) | 1283 if(MPV_common_init(s) < 0) |
1284 return -1; | 1284 return -1; |
1285 r->intra_types_hist = av_realloc(r->intra_types_hist, s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist)); | 1285 r->intra_types_stride = s->mb_width*4 + 4; |
1286 r->intra_types = r->intra_types_hist + s->b4_stride * 4; | 1286 r->intra_types_hist = av_realloc(r->intra_types_hist, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); |
1287 r->intra_types = r->intra_types_hist + r->intra_types_stride * 4; | |
1287 r->mb_type = av_realloc(r->mb_type, r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type)); | 1288 r->mb_type = av_realloc(r->mb_type, r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type)); |
1288 r->cbp_luma = av_realloc(r->cbp_luma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma)); | 1289 r->cbp_luma = av_realloc(r->cbp_luma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma)); |
1289 r->cbp_chroma = av_realloc(r->cbp_chroma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma)); | 1290 r->cbp_chroma = av_realloc(r->cbp_chroma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma)); |
1290 r->deblock_coefs = av_realloc(r->deblock_coefs, r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs)); | 1291 r->deblock_coefs = av_realloc(r->deblock_coefs, r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs)); |
1291 } | 1292 } |
1311 if(r->si.start != mb_pos){ | 1312 if(r->si.start != mb_pos){ |
1312 av_log(s->avctx, AV_LOG_ERROR, "Slice indicates MB offset %d, got %d\n", r->si.start, mb_pos); | 1313 av_log(s->avctx, AV_LOG_ERROR, "Slice indicates MB offset %d, got %d\n", r->si.start, mb_pos); |
1313 s->mb_x = r->si.start % s->mb_width; | 1314 s->mb_x = r->si.start % s->mb_width; |
1314 s->mb_y = r->si.start / s->mb_width; | 1315 s->mb_y = r->si.start / s->mb_width; |
1315 } | 1316 } |
1316 memset(r->intra_types_hist, -1, s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist)); | 1317 memset(r->intra_types_hist, -1, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); |
1317 s->first_slice_line = 1; | 1318 s->first_slice_line = 1; |
1318 s->resync_mb_x= s->mb_x; | 1319 s->resync_mb_x= s->mb_x; |
1319 s->resync_mb_y= s->mb_y; | 1320 s->resync_mb_y= s->mb_y; |
1320 | 1321 |
1321 ff_init_block_index(s); | 1322 ff_init_block_index(s); |
1322 while(!check_slice_end(r, s)) { | 1323 while(!check_slice_end(r, s)) { |
1323 ff_update_block_index(s); | 1324 ff_update_block_index(s); |
1324 s->dsp.clear_blocks(s->block[0]); | 1325 s->dsp.clear_blocks(s->block[0]); |
1325 | 1326 |
1326 if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 1) < 0){ | 1327 if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 4) < 0){ |
1327 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR); | 1328 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR); |
1328 return -1; | 1329 return -1; |
1329 } | 1330 } |
1330 if (++s->mb_x == s->mb_width) { | 1331 if (++s->mb_x == s->mb_width) { |
1331 s->mb_x = 0; | 1332 s->mb_x = 0; |
1332 s->mb_y++; | 1333 s->mb_y++; |
1333 ff_init_block_index(s); | 1334 ff_init_block_index(s); |
1334 | 1335 |
1335 memmove(r->intra_types_hist, r->intra_types, s->b4_stride * 4 * sizeof(*r->intra_types_hist)); | 1336 memmove(r->intra_types_hist, r->intra_types, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist)); |
1336 memset(r->intra_types, -1, s->b4_stride * 4 * sizeof(*r->intra_types_hist)); | 1337 memset(r->intra_types, -1, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist)); |
1337 | 1338 |
1338 if(r->loop_filter && s->mb_y >= 2) | 1339 if(r->loop_filter && s->mb_y >= 2) |
1339 r->loop_filter(r, s->mb_y - 2); | 1340 r->loop_filter(r, s->mb_y - 2); |
1340 } | 1341 } |
1341 if(s->mb_x == s->resync_mb_x) | 1342 if(s->mb_x == s->resync_mb_x) |
1375 if (MPV_common_init(s) < 0) | 1376 if (MPV_common_init(s) < 0) |
1376 return -1; | 1377 return -1; |
1377 | 1378 |
1378 ff_h264_pred_init(&r->h, CODEC_ID_RV40); | 1379 ff_h264_pred_init(&r->h, CODEC_ID_RV40); |
1379 | 1380 |
1380 r->intra_types_hist = av_malloc(s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist)); | 1381 r->intra_types_stride = 4*s->mb_stride + 4; |
1381 r->intra_types = r->intra_types_hist + s->b4_stride * 4; | 1382 r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); |
1383 r->intra_types = r->intra_types_hist + r->intra_types_stride * 4; | |
1382 | 1384 |
1383 r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type)); | 1385 r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type)); |
1384 | 1386 |
1385 r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma)); | 1387 r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma)); |
1386 r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma)); | 1388 r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma)); |