Mercurial > libavcodec.hg
comparison raw.c @ 2375:24d3a50d1b8b libavcodec
raw rgb flip fix
author | michael |
---|---|
date | Tue, 30 Nov 2004 21:50:16 +0000 |
parents | d9c9b42767da |
children | b2846918585c |
comparison
equal
deleted
inserted
replaced
2374:b36811e1386a | 2375:24d3a50d1b8b |
---|---|
104 return -1; | 104 return -1; |
105 | 105 |
106 return 0; | 106 return 0; |
107 } | 107 } |
108 | 108 |
109 static void flip(AVCodecContext *avctx, AVPicture * picture){ | |
110 if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[1]==0){ | |
111 picture->data[0] += picture->linesize[0] * (avctx->height-1); | |
112 picture->linesize[0] *= -1; | |
113 } | |
114 } | |
115 | |
109 static int raw_decode(AVCodecContext *avctx, | 116 static int raw_decode(AVCodecContext *avctx, |
110 void *data, int *data_size, | 117 void *data, int *data_size, |
111 uint8_t *buf, int buf_size) | 118 uint8_t *buf, int buf_size) |
112 { | 119 { |
113 RawVideoContext *context = avctx->priv_data; | 120 RawVideoContext *context = avctx->priv_data; |
116 AVPicture * picture = (AVPicture *) data; | 123 AVPicture * picture = (AVPicture *) data; |
117 | 124 |
118 /* Early out without copy if packet size == frame size */ | 125 /* Early out without copy if packet size == frame size */ |
119 if (buf_size == context->length && context->p == context->buffer) { | 126 if (buf_size == context->length && context->p == context->buffer) { |
120 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); | 127 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); |
128 flip(avctx, picture); | |
121 *data_size = sizeof(AVPicture); | 129 *data_size = sizeof(AVPicture); |
122 return buf_size; | 130 return buf_size; |
123 } | 131 } |
124 | 132 |
125 bytesNeeded = context->length - (context->p - context->buffer); | 133 bytesNeeded = context->length - (context->p - context->buffer); |
130 } | 138 } |
131 | 139 |
132 memcpy(context->p, buf, bytesNeeded); | 140 memcpy(context->p, buf, bytesNeeded); |
133 context->p = context->buffer; | 141 context->p = context->buffer; |
134 avpicture_fill(picture, context->buffer, avctx->pix_fmt, avctx->width, avctx->height); | 142 avpicture_fill(picture, context->buffer, avctx->pix_fmt, avctx->width, avctx->height); |
143 flip(avctx, picture); | |
135 *data_size = sizeof(AVPicture); | 144 *data_size = sizeof(AVPicture); |
136 return bytesNeeded; | 145 return bytesNeeded; |
137 } | 146 } |
138 | 147 |
139 static int raw_close_decoder(AVCodecContext *avctx) | 148 static int raw_close_decoder(AVCodecContext *avctx) |