2
stores macroblock infos
3
Copyright (C) 2000 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
14
#include "macroBlock.h"
16
#define DEBUG_MACROBLOCK(x)
17
//#define DEBUG_MACROBLOCK(x) x
21
MacroBlock::MacroBlock(VideoDecoder* vid_stream) {
22
this->vid_stream=vid_stream;
23
copyFunctions=new CopyFunctions();
27
MacroBlock::~MacroBlock() {
33
*--------------------------------------------------------------
37
* Parseoff macroblock. Reconstructs DCT values. Applies
38
* inverse DCT, reconstructs motion vectors, calculates and
39
* set pixel values for macroblock in current pict image
43
* Here's where everything really happens. Welcome to the
47
* Bit stream irreversibly parsed off.
49
*--------------------------------------------------------------
52
int MacroBlock::processMacroBlock(PictureArray* pictureArray) {
54
int recon_right_for, recon_down_for, recon_right_back,
56
int mb_quant = 0, mb_motion_forw = 0, mb_motion_back = 0,
60
MpegVideoStream* mpegVideoStream=vid_stream->mpegVideoStream;
61
DecoderClass* decoderClass=vid_stream->decoderClass;
64
* Parse off macroblock address increment and add to macroblock address.
67
addr_incr=decoderClass->decodeMBAddrInc();
68
if (addr_incr==MB_ESCAPE) {
70
addr_incr=MB_STUFFING;
73
} while (addr_incr == MB_STUFFING);
74
mb_address+=addr_incr;
78
if (mb_address > (vid_stream->mpegVideoHeader)->getMB_Size()) {
80
DEBUG_MACROBLOCK(cout <<"ParseMacroBlock: SKIP_TO_START_CODE"<<endl;)
81
DEBUG_MACROBLOCK(cout <<"mb_address "<<mb_address<<endl;)
83
int h=(vid_stream->mpegVideoHeader)->getMB_Height();
84
int w=(vid_stream->mpegVideoHeader)->getMB_Width();
87
DEBUG_MACROBLOCK(cout <<"mb_height*mb_width-1:"<<(h*w - 1)<<endl;)
92
* If macroblocks have been skipped, process skipped macroblocks.
95
int code_type=(vid_stream->picture)->getCodeType();
97
if (mb_address - past_mb_addr > 1) {
99
processSkippedPictures(pictureArray,code_type,
100
(vid_stream->mpegVideoHeader)->getMB_Width());
105
/* Set past macroblock address to current macroblock address. */
106
past_mb_addr = mb_address;
107
/* Based on picture type decode macroblock type. */
112
decoderClass->decodeMBTypeI(mb_quant, mb_motion_forw,
113
mb_motion_back, mb_pattern,
118
decoderClass->decodeMBTypeP(mb_quant, mb_motion_forw,
119
mb_motion_back, mb_pattern,
124
decoderClass->decodeMBTypeB(mb_quant, mb_motion_forw,
125
mb_motion_back, mb_pattern,
129
DEBUG_MACROBLOCK(cout <<"ERROR: MPEG-1 Streams with D-frames are not supported"<<endl;)
133
/* If quantization flag set, parse off new quantization scale. */
134
if (mb_quant == true) {
135
data=mpegVideoStream->getBits(5);
136
(vid_stream->slice)->setQuantScale(data);
138
/* If forward motion vectors exist... */
140
if (mb_motion_forw == true) {
141
// Parse off and decode horizontal forward motion vector.
142
motion_h_forw_code=decoderClass->decodeMotionVectors();
144
// If horiz. forward r data exists, parse off.
146
if ((vid_stream->picture->getForw_f() != 1) &&
147
(motion_h_forw_code != 0)) {
148
data=vid_stream->picture->geth_forw_r(mpegVideoStream);
149
motion_h_forw_r = data;
151
// Parse off and decode vertical forward motion vector.
153
motion_v_forw_code=decoderClass->decodeMotionVectors();
155
// If vert. forw. r data exists, parse off.
157
if ((vid_stream->picture->getForw_f() != 1) &&
158
(motion_v_forw_code != 0)) {
160
data=vid_stream->picture->getv_forw_r(mpegVideoStream);
161
motion_v_forw_r = data;
165
/* If back motion vectors exist... */
167
if (mb_motion_back == true) {
168
// Parse off and decode horiz. back motion vector.
169
motion_h_back_code=decoderClass->decodeMotionVectors();
171
// If horiz. back r data exists, parse off.
173
if ((vid_stream->picture->getBack_f() != 1) &&
174
(motion_h_back_code != 0)) {
175
data=vid_stream->picture->geth_back_r(mpegVideoStream);
176
motion_h_back_r = data;
178
// Parse off and decode vert. back motion vector.
179
motion_v_back_code=decoderClass->decodeMotionVectors();
181
// If vert. back r data exists, parse off.
183
if ((vid_stream->picture->getBack_f() != 1) &&
184
(motion_v_back_code != 0)) {
185
data=vid_stream->picture->getv_back_r(mpegVideoStream);
186
motion_v_back_r = data;
190
/* If mblock pattern flag set, parse and decode CBP (code block pattern). */
191
if (mb_pattern == true) {
192
cbp=decoderClass->decodeCBP();
194
/* Otherwise, set CBP to zero. */
200
/* Reconstruct motion vectors depending on picture type. */
201
if (code_type == P_TYPE) {
204
* If no forw motion vectors, reset previous and current vectors to 0.
206
if (!mb_motion_forw) {
209
recon_right_for_prev = 0;
210
recon_down_for_prev = 0;
213
* Otherwise, compute new forw motion vectors. Reset previous vectors to
218
computeForwVector(&recon_right_for, &recon_down_for);
222
if (code_type == B_TYPE) {
224
/* Reset prev. and current vectors to zero if mblock is intracoded. */
226
recon_right_for_prev = 0;
227
recon_down_for_prev = 0;
228
recon_right_back_prev = 0;
229
recon_down_back_prev = 0;
232
/* If no forw vectors, current vectors equal prev. vectors. */
234
if (!mb_motion_forw) {
235
recon_right_for = recon_right_for_prev;
236
recon_down_for = recon_down_for_prev;
239
* Otherwise compute forw. vectors. Reset prev vectors to new values.
243
computeForwVector(&recon_right_for, &recon_down_for);
247
/* If no back vectors, set back vectors to prev back vectors. */
249
if (!mb_motion_back) {
250
recon_right_back = recon_right_back_prev;
251
recon_down_back = recon_down_back_prev;
253
/* Otherwise compute new vectors and reset prev. back vectors. */
256
computeBackVector(&recon_right_back,&recon_down_back);
261
* Store vector existence flags in structure for possible skipped
262
* macroblocks to follow.
265
bpict_past_forw = mb_motion_forw;
266
bpict_past_back = mb_motion_back;
270
back=reconstruct(recon_right_for,
279
/* If D Type picture, flush marker bit. */
280
if (code_type == D_TYPE) {
281
mpegVideoStream->flushBits(1);
284
/* If macroblock was intracoded, set macroblock past intra address. */
286
past_intra_addr=mb_address;
295
int MacroBlock::resetMacroBlock() {
296
/* Reset past intrablock address. */
297
past_intra_addr = -2;
299
/* Reset previous recon motion vectors. */
302
recon_right_for_prev = 0;
303
recon_down_for_prev = 0;
304
recon_right_back_prev = 0;
305
recon_down_back_prev = 0;
307
/* Reset macroblock address. */
308
mb_address = (((vid_stream->slice)->getVertPos()-1) *
309
(vid_stream->mpegVideoHeader)->getMB_Width()) - 1;
315
int MacroBlock::resetPastMacroBlock() {
316
/* Reset past macroblock address field. */
325
int MacroBlock::reconstruct(int& recon_right_for,
327
int& recon_right_back,
328
int& recon_down_back,
331
PictureArray* pictureArray) {
336
int mb_width=(vid_stream->mpegVideoHeader)->getMB_Width();
337
int row_size=pictureArray->getWidth();
338
short int* dct_start=(vid_stream->decoderClass)->getDCT();
339
unsigned int qscale=(vid_stream->slice)->getQuantScale();
340
int codeType=(vid_stream->picture)->getCodeType();
341
DecoderClass* decoderClass=vid_stream->decoderClass;
343
Recon* recon=vid_stream->recon;
344
unsigned int* iqmatrixptr=
345
(vid_stream->mpegVideoHeader)->getIntra_quant_matrix();
346
unsigned int* niqmatrixptr=
347
(vid_stream->mpegVideoHeader)->getNon_intra_quant_matrix();
353
if (mb_address-past_intra_addr > 1) {
358
DEBUG_MACROBLOCK(cout << "mb_width <= 0"<<endl;)
361
/* Calculate macroblock row and column from address. */
362
mb_row=mb_address / mb_width;
363
mb_col=mb_address % mb_width;
365
copyFunctions->startNOFloatSection();
367
for (mask = 32, i = 0; i < 6; mask >>= 1, i++) {
370
/* If block exists... */
371
if ((mb_intra) || (cbp & mask)) {
373
//copyFunctions->endNOFloatSection();
374
decoderClass->ParseReconBlock(i,mb_intra,
375
qscale,lflag,iqmatrixptr,niqmatrixptr);
376
//copyFunctions->endNOFloatSection();
382
// If macroblock is intra coded...
386
recon->ReconIMBlock(i,mb_row,mb_col,row_size,
387
dct_start,pictureArray);
388
//copyFunctions->endNOFloatSection();
389
} else if (mb_motion_forw && mb_motion_back) {
390
recon->ReconBiMBlock(i,recon_right_for,
391
recon_down_for,recon_right_back,
392
recon_down_back,zero_block_flag,
393
mb_row,mb_col,row_size,dct_start,
395
//copyFunctions->endNOFloatSection();
396
} else if (mb_motion_forw || (codeType ==P_TYPE)){
397
recon->ReconPMBlock(i,recon_right_for,
398
recon_down_for,zero_block_flag,
399
mb_row,mb_col,row_size,dct_start,
400
pictureArray, codeType);
401
//copyFunctions->endNOFloatSection();
402
} else if (mb_motion_back) {
403
recon->ReconBMBlock(i,recon_right_back,
404
recon_down_back,zero_block_flag,
405
mb_row,mb_col,row_size,dct_start,
407
//copyFunctions->endNOFloatSection();
410
//DEBUG_MACROBLOCK(cout << "nothing"<<endl;)
414
copyFunctions->endNOFloatSection();
419
*--------------------------------------------------------------
421
* ComputeForwVector --
423
* Computes forward motion vector by calling ComputeVector
424
* with appropriate parameters.
427
* Reconstructed motion vector placed in recon_right_for_ptr and
428
* recon_down_for_ptr.
433
*--------------------------------------------------------------
436
void MacroBlock::computeForwVector(int* recon_right_for_ptr,
437
int* recon_down_for_ptr) {
442
picture = vid_stream->picture;
445
unsigned int forw_f=picture->getForw_f();
446
unsigned int full_pel_forw_vector=picture->getFull_pel_forw_vector();
447
vid_stream->motionVector->computeVector(recon_right_for_ptr,
449
recon_right_for_prev,
452
full_pel_forw_vector,
457
picture->setForw_f(forw_f);
458
picture->setFull_pel_forw_vector(full_pel_forw_vector);
463
*--------------------------------------------------------------
465
* ComputeBackVector --
467
* Computes backward motion vector by calling ComputeVector
468
* with appropriate parameters.
471
* Reconstructed motion vector placed in recon_right_back_ptr and
472
* recon_down_back_ptr.
477
*--------------------------------------------------------------
480
void MacroBlock::computeBackVector(int* recon_right_back_ptr,
481
int* recon_down_back_ptr) {
486
picture = vid_stream->picture;
489
unsigned int back_f=picture->getBack_f();
490
unsigned int full_pel_back_vector=picture->getFull_pel_back_vector();
492
vid_stream->motionVector->computeVector(recon_right_back_ptr,
494
recon_right_back_prev,
495
recon_down_back_prev,
497
full_pel_back_vector,
502
picture->setBack_f(back_f);
503
picture->setFull_pel_back_vector(full_pel_back_vector);
510
int MacroBlock::processSkippedPictures(PictureArray* pictureArray,
513
copyFunctions->startNOFloatSection();
515
if (code_type == P_TYPE) {
517
ProcessSkippedPFrameMBlocks(pictureArray->getCurrent(),
518
pictureArray->getFuture(),
522
if (code_type == B_TYPE) {
523
ProcessSkippedBFrameMBlocks(vid_stream->picture,
524
pictureArray->getPast(),
525
pictureArray->getCurrent(),
526
pictureArray->getFuture(),
531
copyFunctions->endNOFloatSection();
537
*--------------------------------------------------------------
539
* ProcessSkippedPFrameMBlocks --
541
* Processes skipped macroblocks in P frames.
544
* Calculates pixel values for luminance, Cr, and Cb planes
545
* in current pict image for skipped macroblocks.
548
* Pixel values in pict image changed.
550
*--------------------------------------------------------------
552
void MacroBlock::ProcessSkippedPFrameMBlocks(YUVPicture* current,
556
int row_size, half_row, mb_row, mb_col, row, col, rr;
557
int addr, row_incr, half_row_incr, crow, ccol;
558
int *dest, *src, *dest1, *src1;
560
/* For each row in macroblock luminance plane... */
562
DEBUG_MACROBLOCK(cout << "mb_width in skipped is 0"<<endl;)
567
/* Calculate row sizes for luminance and Cr/Cb macroblock areas. */
569
row_size = mb_width << 4;
570
half_row = (row_size >> 1);
571
row_incr = row_size >> 2;
572
half_row_incr = half_row >> 2;
574
/* For each skipped macroblock, do... */
575
int lumEnd=current->getLumLength();
576
int colorEnd=current->getColorLength();
578
unsigned char *picDest;
579
unsigned char *picSrc;
581
unsigned char *picDestStart;
582
unsigned char *picSrcStart;
586
for (addr = past_mb_addr + 1; addr < mb_address; addr++) {
588
/* Calculate macroblock row and col. */
590
mb_row = addr / mb_width;
591
mb_col = addr % mb_width;
593
/* Calculate upper left pixel row,col for luminance plane. */
598
picDest=current->getLuminancePtr();
599
picSrc=future->getLuminancePtr();
601
picDestStart=(picDest+(row*row_size)+col);
602
picSrcStart=(picSrc+(row*row_size)+col);
604
if ((picDestStart+7*row_size+7 >= picDest+lumEnd) ||
605
(picDestStart < picDest)) {
606
DEBUG_MACROBLOCK(cout << "urg! last resort caught before sigsev skipped -1"<<endl;)
609
if ((picSrcStart+7*row_size+7 >= picSrc+lumEnd) ||
610
(picSrcStart < picSrc)) {
611
DEBUG_MACROBLOCK(cout << "urg! last resort caught before sigsev skipped -2"<<endl;)
615
dest=(int*)picDestStart;
616
src=(int*)picSrcStart;
620
for (rr = 0; rr < 8; rr++) {
622
/* Copy pixel values from last I or P picture. */
623
memcpy(dest,src,sizeof(int)*4);
627
memcpy(dest,src,sizeof(int)*4);
634
* Divide row,col to get upper left pixel of macroblock in Cr and Cb
641
/* For each row in Cr, and Cb planes... */
642
picDest=current->getCrPtr();
643
picDestStart=(picDest+(crow*half_row)+ccol);
644
if ((picDestStart+7*half_row_incr+7 >= picDest+colorEnd) ||
645
(picDestStart < picDest)) {
646
DEBUG_MACROBLOCK(cout << "urg! last resort caught before sigsev skipped -3"<<endl;)
651
dest=(int*)(current->getCrPtr()+(crow*half_row)+ccol);
652
src=(int*)(future->getCrPtr()+(crow*half_row)+ccol);
653
dest1=(int*)(current->getCbPtr()+(crow*half_row)+ccol);
654
src1=(int*)(future->getCbPtr()+(crow*half_row)+ccol);
656
for (rr = 0; rr < 4; rr++) {
658
/* Copy pixel values from last I or P picture. */
659
memcpy(dest,src,sizeof(int)*2);
660
memcpy(dest1,src1,sizeof(int)*2);
663
dest += half_row_incr;
664
src += half_row_incr;
665
dest1 += half_row_incr;
666
src1 += half_row_incr;
668
memcpy(dest,src,sizeof(int)*2);
669
memcpy(dest1,src1,sizeof(int)*2);
671
dest += half_row_incr;
672
src += half_row_incr;
673
dest1 += half_row_incr;
674
src1 += half_row_incr;
679
recon_right_for_prev = 0;
680
recon_down_for_prev = 0;
689
*--------------------------------------------------------------
691
* ProcessSkippedBFrameMBlocks --
693
* Processes skipped macroblocks in B frames.
696
* Calculates pixel values for luminance, Cr, and Cb planes
697
* in current pict image for skipped macroblocks.
700
* Pixel values in pict image changed.
702
*--------------------------------------------------------------
705
void MacroBlock::ProcessSkippedBFrameMBlocks(Picture* picture,
710
int row_size, half_row, mb_row, mb_col, row, col, rr;
711
int right_half_for = 0, down_half_for = 0;
712
int c_right_half_for = 0, c_down_half_for = 0;
713
int right_half_back = 0, down_half_back = 0;
714
int c_right_half_back = 0, c_down_half_back = 0;
715
int addr, right_for = 0, down_for = 0;
716
int recon_right_for, recon_down_for;
717
int recon_right_back, recon_down_back;
718
int right_back = 0, down_back = 0;
719
int c_right_for = 0, c_down_for = 0;
720
int c_right_back = 0, c_down_back = 0;
721
unsigned char forw_lum[256];
722
unsigned char forw_cr[64], forw_cb[64];
723
unsigned char back_lum[256], back_cr[64], back_cb[64];
724
int row_incr, half_row_incr;
728
/* Calculate row sizes for luminance and Cr/Cb macroblock areas. */
731
DEBUG_MACROBLOCK(cout << "mb_width in skipped is 0 (2)"<<endl;)
735
row_size = mb_width << 4;
736
half_row = (row_size >> 1);
737
row_incr = row_size >> 2;
738
half_row_incr = half_row >> 2;
740
/* Establish motion vector codes based on full pixel flag. */
742
if (picture->getFull_pel_forw_vector()) {
743
recon_right_for = recon_right_for_prev << 1;
744
recon_down_for = recon_down_for_prev << 1;
746
recon_right_for = recon_right_for_prev;
747
recon_down_for = recon_down_for_prev;
750
if (picture->getFull_pel_back_vector()) {
751
recon_right_back = recon_right_back_prev << 1;
752
recon_down_back = recon_down_back_prev << 1;
754
recon_right_back = recon_right_back_prev;
755
recon_down_back = recon_down_back_prev;
759
/* If only one motion vector, do display copy, else do full
763
/* Calculate motion vectors. */
765
if (bpict_past_forw) {
766
right_for = recon_right_for >> 1;
767
down_for = recon_down_for >> 1;
768
right_half_for = recon_right_for & 0x1;
769
down_half_for = recon_down_for & 0x1;
771
recon_right_for /= 2;
773
c_right_for = recon_right_for >> 1;
774
c_down_for = recon_down_for >> 1;
775
c_right_half_for = recon_right_for & 0x1;
776
c_down_half_for = recon_down_for & 0x1;
779
if (bpict_past_back) {
780
right_back = recon_right_back >> 1;
781
down_back = recon_down_back >> 1;
782
right_half_back = recon_right_back & 0x1;
783
down_half_back = recon_down_back & 0x1;
785
recon_right_back /= 2;
786
recon_down_back /= 2;
787
c_right_back = recon_right_back >> 1;
788
c_down_back = recon_down_back >> 1;
789
c_right_half_back = recon_right_back & 0x1;
790
c_down_half_back = recon_down_back & 0x1;
793
/* For each skipped macroblock, do... */
795
for (addr = past_mb_addr + 1;
796
addr < mb_address; addr++) {
798
/* Calculate macroblock row and col. */
800
mb_row = addr / mb_width;
801
mb_col = addr % mb_width;
803
/* Calculate upper left pixel row,col for luminance plane. */
810
/* If forward predicted, calculate prediction values. */
811
if (bpict_past_forw) {
812
int lumEnd=current->getLumLength();
813
int colorEnd=current->getColorLength();
814
ReconSkippedBlock(past->getLuminancePtr(),
815
forw_lum,row,col,row_size,
818
down_half_for,16,lumEnd);
819
ReconSkippedBlock(past->getCrPtr(),
820
forw_cr,crow,ccol, half_row,
821
c_right_for,c_down_for,
823
c_down_half_for,8,colorEnd);
824
ReconSkippedBlock(past->getCbPtr(),
825
forw_cb,crow,ccol,half_row,
826
c_right_for,c_down_for,
828
c_down_half_for,8,colorEnd);
830
/* If back predicted, calculate prediction values. */
832
if (bpict_past_back) {
833
int lumEnd=current->getLumLength();
834
int colorEnd=current->getColorLength();
835
ReconSkippedBlock(future->getLuminancePtr(),
836
back_lum,row,col,row_size,
837
right_back,down_back,
838
right_half_back,down_half_back,
840
ReconSkippedBlock(future->getCrPtr(),
842
half_row,c_right_back,
843
c_down_back,c_right_half_back,
844
c_down_half_back,8,colorEnd);
845
ReconSkippedBlock(future->getCbPtr(),
846
back_cb,crow,ccol,half_row,
847
c_right_back,c_down_back,
849
c_down_half_back,8,colorEnd);
851
unsigned char* picDest=current->getLuminancePtr();
852
int lumEnd=current->getLumLength();
853
int colorEnd=current->getColorLength();
855
unsigned char* picDestStart=(picDest+(row*row_size)+col);
858
if ((picDestStart+7*row_size+7 >= picDest+lumEnd) ||
859
(picDestStart < picDest)) {
860
DEBUG_MACROBLOCK(cout << "urg! last resort caught before sigsev skipped -4"<<endl;)
864
picDest=current->getCrPtr();
865
picDestStart=(picDest+(crow*half_row)+ccol);
866
if ((picDestStart+7*half_row_incr+7 >= picDest+colorEnd) ||
867
(picDestStart < picDest)) {
868
DEBUG_MACROBLOCK(cout << "urg! last resort caught before sigsev skipped -5"<<endl;)
873
if (bpict_past_forw && !bpict_past_back) {
877
dest=(int*)(current->getLuminancePtr()+(row*row_size)+col);
880
for (rr = 0; rr < 16; rr++) {
882
/* memcpy(dest, forw_lum+(rr<<4), 16); */
892
dest = (int*)(current->getCrPtr()+(crow*half_row)+ccol);
893
dest1 = (int*)(current->getCbPtr()+(crow*half_row)+ccol);
895
src1 = (int*)forw_cb;
897
for (rr = 0; rr < 8; rr++) {
899
* memcpy(dest, forw_cr+(rr<<3), 8); memcpy(dest1, forw_cb+(rr<<3),
909
dest += half_row_incr;
910
dest1 += half_row_incr;
914
} else if (bpict_past_back && !bpict_past_forw) {
918
dest=(int*)(current->getLuminancePtr()+(row*row_size)+col);
919
src = (int*)back_lum;
921
for (rr = 0; rr < 16; rr++) {
931
dest = (int *)(current->getCrPtr()+(crow*half_row)+ccol);
932
dest1 = (int *)(current->getCbPtr()+(crow*half_row)+ccol);
933
src = (int *)back_cr;
934
src1 = (int *)back_cb;
936
for (rr = 0; rr < 8; rr++) {
938
* memcpy(dest, back_cr+(rr<<3), 8); memcpy(dest1, back_cb+(rr<<3),
948
dest += half_row_incr;
949
dest1 += half_row_incr;
955
unsigned char *src1, *src2, *src1a, *src2a;
956
unsigned char *dest, *dest1;
957
dest = current->getLuminancePtr()+(row*row_size)+col;
961
for (rr = 0; rr < 16; rr++) {
962
dest[0] = (int) (src1[0] + src2[0]) >> 1;
963
dest[1] = (int) (src1[1] + src2[1]) >> 1;
964
dest[2] = (int) (src1[2] + src2[2]) >> 1;
965
dest[3] = (int) (src1[3] + src2[3]) >> 1;
966
dest[4] = (int) (src1[4] + src2[4]) >> 1;
967
dest[5] = (int) (src1[5] + src2[5]) >> 1;
968
dest[6] = (int) (src1[6] + src2[6]) >> 1;
969
dest[7] = (int) (src1[7] + src2[7]) >> 1;
970
dest[8] = (int) (src1[8] + src2[8]) >> 1;
971
dest[9] = (int) (src1[9] + src2[9]) >> 1;
972
dest[10] = (int) (src1[10] + src2[10]) >> 1;
973
dest[11] = (int) (src1[11] + src2[11]) >> 1;
974
dest[12] = (int) (src1[12] + src2[12]) >> 1;
975
dest[13] = (int) (src1[13] + src2[13]) >> 1;
976
dest[14] = (int) (src1[14] + src2[14]) >> 1;
977
dest[15] = (int) (src1[15] + src2[15]) >> 1;
984
dest = current->getCrPtr() + (crow * half_row) + ccol;
985
dest1 = current->getCbPtr() + (crow * half_row) + ccol;
991
for (rr = 0; rr < 8; rr++) {
992
dest[0] = (int) (src1[0] + src2[0]) >> 1;
993
dest[1] = (int) (src1[1] + src2[1]) >> 1;
994
dest[2] = (int) (src1[2] + src2[2]) >> 1;
995
dest[3] = (int) (src1[3] + src2[3]) >> 1;
996
dest[4] = (int) (src1[4] + src2[4]) >> 1;
997
dest[5] = (int) (src1[5] + src2[5]) >> 1;
998
dest[6] = (int) (src1[6] + src2[6]) >> 1;
999
dest[7] = (int) (src1[7] + src2[7]) >> 1;
1004
dest1[0] = (int) (src1a[0] + src2a[0]) >> 1;
1005
dest1[1] = (int) (src1a[1] + src2a[1]) >> 1;
1006
dest1[2] = (int) (src1a[2] + src2a[2]) >> 1;
1007
dest1[3] = (int) (src1a[3] + src2a[3]) >> 1;
1008
dest1[4] = (int) (src1a[4] + src2a[4]) >> 1;
1009
dest1[5] = (int) (src1a[5] + src2a[5]) >> 1;
1010
dest1[6] = (int) (src1a[6] + src2a[6]) >> 1;
1011
dest1[7] = (int) (src1a[7] + src2a[7]) >> 1;
1028
*--------------------------------------------------------------
1030
* ReconSkippedBlock --
1032
* Reconstructs predictive block for skipped macroblocks
1041
*--------------------------------------------------------------
1043
void MacroBlock::ReconSkippedBlock(unsigned char* source,
1044
unsigned char* dest,
1052
int width,int maxLen) {
1054
unsigned char *source2;
1057
tmp = source+((row + down) * row_size) + col + right;
1060
if ((tmp+7*row_size+7 >= source+maxLen) ||
1062
DEBUG_MACROBLOCK(cout << "urg! last resort caught before sigsev skipped -6"<<endl;)
1068
if ((!right_half) && (!down_half)) {
1070
/* No alignment, use bye copy */
1071
for (rr = 0; rr < 16; rr++) {
1073
memcpy(dest,source,sizeof(char)*16);
1078
} else if (right & 0x2) {
1079
/* Half-word bit aligned, use 16 bit copy */
1080
short *src = (short *)source;
1081
short *d = (short *)dest;
1083
for (rr = 0; rr < 16; rr++) {
1085
memcpy(d,src,sizeof(short)*8);
1091
/* Word aligned, use 32 bit copy */
1092
int *src = (int *)source;
1093
int *d = (int *)dest;
1095
for (rr = 0; rr < 16; rr++) {
1105
source2 = source + right_half + (row_size * down_half);
1106
copyFunctions->copy16_div2_destlinear_nocrop(source,source2,dest,
1111
} else { /* (width == 8) */
1113
if ((!right_half) && (!down_half)) {
1115
for (rr = 0; rr < width; rr++) {
1117
memcpy(dest,source,sizeof(char)*8);
1122
} else if (right & 0x02) {
1123
short *d = (short *)dest;
1124
short *src = (short *)source;
1126
for (rr = 0; rr < width; rr++) {
1135
int *d = (int *)dest;
1136
int *src = (int *)source;
1138
for (rr = 0; rr < width; rr++) {
1146
source2 = source + right_half + (row_size * down_half);
1147
copyFunctions->copy8_div2_destlinear_nocrop(source,source2,