Mercurial > libavcodec.hg
comparison roqvideoenc.c @ 5198:579c01dbb5a1 libavcodec
use properly AVFrame.linesize
patch by Vitor: [vitor1001 gmail com]
author | benoit |
---|---|
date | Mon, 02 Jul 2007 10:20:12 +0000 |
parents | 4870b71fe348 |
children | 922bb0564bd3 |
comparison
equal
deleted
inserted
replaced
5197:953a9fd3b5f5 | 5198:579c01dbb5a1 |
---|---|
123 } | 123 } |
124 | 124 |
125 // FIXME Could use DSPContext.sse, but it is not so speed critical (used | 125 // FIXME Could use DSPContext.sse, but it is not so speed critical (used |
126 // just for motion estimation). | 126 // just for motion estimation). |
127 static int block_sse(uint8_t **buf1, uint8_t **buf2, int x1, int y1, int x2, | 127 static int block_sse(uint8_t **buf1, uint8_t **buf2, int x1, int y1, int x2, |
128 int y2, int *stride, int size) | 128 int y2, int *stride1, int *stride2, int size) |
129 { | 129 { |
130 int i, k; | 130 int i, k; |
131 int sse=0; | 131 int sse=0; |
132 | 132 |
133 for (k=0; k<3; k++) { | 133 for (k=0; k<3; k++) { |
134 int bias = (k ? CHROMA_BIAS : 4); | 134 int bias = (k ? CHROMA_BIAS : 4); |
135 for (i=0; i<size; i++) | 135 for (i=0; i<size; i++) |
136 sse += bias*eval_sse(buf1[k] + (y1+i)*stride[k] + x1, | 136 sse += bias*eval_sse(buf1[k] + (y1+i)*stride1[k] + x1, |
137 buf2[k] + (y2+i)*stride[k] + x2, size); | 137 buf2[k] + (y2+i)*stride2[k] + x2, size); |
138 } | 138 } |
139 | 139 |
140 return sse; | 140 return sse; |
141 } | 141 } |
142 | 142 |
157 | 157 |
158 if ((unsigned) mx > enc->width-size || (unsigned) my > enc->height-size) | 158 if ((unsigned) mx > enc->width-size || (unsigned) my > enc->height-size) |
159 return INT_MAX; | 159 return INT_MAX; |
160 | 160 |
161 return block_sse(enc->frame_to_enc->data, enc->last_frame->data, x, y, | 161 return block_sse(enc->frame_to_enc->data, enc->last_frame->data, x, y, |
162 mx, my, enc->frame_to_enc->linesize, size); | 162 mx, my, |
163 enc->frame_to_enc->linesize, enc->last_frame->linesize, | |
164 size); | |
163 } | 165 } |
164 | 166 |
165 /** | 167 /** |
166 * Returns distortion between two macroblocks | 168 * Returns distortion between two macroblocks |
167 */ | 169 */ |
415 if (enc->framesSinceKeyframe >= 2) | 417 if (enc->framesSinceKeyframe >= 2) |
416 subcel->eval_dist[RoQ_ID_MOT] = block_sse(enc->frame_to_enc->data, | 418 subcel->eval_dist[RoQ_ID_MOT] = block_sse(enc->frame_to_enc->data, |
417 enc->current_frame->data, x, | 419 enc->current_frame->data, x, |
418 y, x, y, | 420 y, x, y, |
419 enc->frame_to_enc->linesize, | 421 enc->frame_to_enc->linesize, |
422 enc->current_frame->linesize, | |
420 4); | 423 4); |
421 else | 424 else |
422 subcel->eval_dist[RoQ_ID_MOT] = INT_MAX; | 425 subcel->eval_dist[RoQ_ID_MOT] = INT_MAX; |
423 | 426 |
424 cluster_index = y*enc->width/16 + x/4; | 427 cluster_index = y*enc->width/16 + x/4; |
477 if (enc->framesSinceKeyframe >= 2) | 480 if (enc->framesSinceKeyframe >= 2) |
478 cel->eval_dist[RoQ_ID_MOT] = block_sse(enc->frame_to_enc->data, | 481 cel->eval_dist[RoQ_ID_MOT] = block_sse(enc->frame_to_enc->data, |
479 enc->current_frame->data, | 482 enc->current_frame->data, |
480 cel->sourceX, cel->sourceY, | 483 cel->sourceX, cel->sourceY, |
481 cel->sourceX, cel->sourceY, | 484 cel->sourceX, cel->sourceY, |
482 enc->frame_to_enc->linesize, 8); | 485 enc->frame_to_enc->linesize, |
486 enc->current_frame->linesize,8); | |
483 else | 487 else |
484 cel->eval_dist[RoQ_ID_MOT] = INT_MAX; | 488 cel->eval_dist[RoQ_ID_MOT] = INT_MAX; |
485 | 489 |
486 get_frame_mb(enc->frame_to_enc, cel->sourceX, cel->sourceY, mb8, 8); | 490 get_frame_mb(enc->frame_to_enc, cel->sourceX, cel->sourceY, mb8, 8); |
487 | 491 |
738 enc->current_frame->data[1], | 742 enc->current_frame->data[1], |
739 enc->current_frame->data[2]}; | 743 enc->current_frame->data[2]}; |
740 av_log(enc->avctx, AV_LOG_ERROR, "Expected distortion: %i Actual: %i\n", | 744 av_log(enc->avctx, AV_LOG_ERROR, "Expected distortion: %i Actual: %i\n", |
741 dist, | 745 dist, |
742 block_sse(fdata, cdata, 0, 0, 0, 0, | 746 block_sse(fdata, cdata, 0, 0, 0, 0, |
743 enc->frame_to_enc->linesize, enc->width)); //WARNING: Square dimensions implied... | 747 enc->frame_to_enc->linesize, |
748 enc->current_frame->linesize, | |
749 enc->width)); //WARNING: Square dimensions implied... | |
744 #endif | 750 #endif |
745 } | 751 } |
746 | 752 |
747 | 753 |
748 /** | 754 /** |
991 RoqContext *enc = avctx->priv_data; | 997 RoqContext *enc = avctx->priv_data; |
992 AVFrame *frame= data; | 998 AVFrame *frame= data; |
993 uint8_t *buf_start = buf; | 999 uint8_t *buf_start = buf; |
994 | 1000 |
995 enc->out_buf = buf; | 1001 enc->out_buf = buf; |
996 enc->y_stride = frame->linesize[0]; | |
997 enc->c_stride = frame->linesize[1]; | |
998 enc->avctx = avctx; | 1002 enc->avctx = avctx; |
999 | 1003 |
1000 enc->frame_to_enc = frame; | 1004 enc->frame_to_enc = frame; |
1001 | 1005 |
1002 if (frame->quality) | 1006 if (frame->quality) |