Mercurial > libavcodec.hg
comparison raw.c @ 2967:ef2149182f1c libavcodec
COSMETICS: Remove all trailing whitespace.
author | diego |
---|---|
date | Sat, 17 Dec 2005 18:14:38 +0000 |
parents | 521756176cbb |
children | bfabfdf9ce55 |
comparison
equal
deleted
inserted
replaced
2966:564788471dd4 | 2967:ef2149182f1c |
---|---|
14 * | 14 * |
15 * You should have received a copy of the GNU Lesser General Public | 15 * You should have received a copy of the GNU Lesser General Public |
16 * License along with this library; if not, write to the Free Software | 16 * License along with this library; if not, write to the Free Software |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 */ | 18 */ |
19 | 19 |
20 /** | 20 /** |
21 * @file raw.c | 21 * @file raw.c |
22 * Raw Video Codec | 22 * Raw Video Codec |
23 */ | 23 */ |
24 | 24 |
25 #include "avcodec.h" | 25 #include "avcodec.h" |
26 | 26 |
27 typedef struct RawVideoContext { | 27 typedef struct RawVideoContext { |
28 unsigned char * buffer; /* block of memory for holding one frame */ | 28 unsigned char * buffer; /* block of memory for holding one frame */ |
29 unsigned char * p; /* current position in buffer */ | 29 unsigned char * p; /* current position in buffer */ |
69 { | 69 { |
70 const PixelFormatTag * tags = pixelFormatTags; | 70 const PixelFormatTag * tags = pixelFormatTags; |
71 while (tags->pix_fmt >= 0) { | 71 while (tags->pix_fmt >= 0) { |
72 if (tags->pix_fmt == fmt) | 72 if (tags->pix_fmt == fmt) |
73 return tags->fourcc; | 73 return tags->fourcc; |
74 tags++; | 74 tags++; |
75 } | 75 } |
76 return 0; | 76 return 0; |
77 } | 77 } |
78 | 78 |
79 /* RAW Decoder Implementation */ | 79 /* RAW Decoder Implementation */ |
90 case 16: avctx->pix_fmt= PIX_FMT_RGB565; break; | 90 case 16: avctx->pix_fmt= PIX_FMT_RGB565; break; |
91 case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break; | 91 case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break; |
92 case 32: avctx->pix_fmt= PIX_FMT_RGBA32; break; | 92 case 32: avctx->pix_fmt= PIX_FMT_RGBA32; break; |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); | 96 context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); |
97 context->buffer = av_malloc(context->length); | 97 context->buffer = av_malloc(context->length); |
98 context->p = context->buffer; | 98 context->p = context->buffer; |
99 context->pic.pict_type = FF_I_TYPE; | 99 context->pic.pict_type = FF_I_TYPE; |
100 context->pic.key_frame = 1; | 100 context->pic.key_frame = 1; |
101 | 101 |
102 avctx->coded_frame= &context->pic; | 102 avctx->coded_frame= &context->pic; |
103 | 103 |
104 if (!context->buffer) | 104 if (!context->buffer) |
105 return -1; | 105 return -1; |
106 | 106 |
107 return 0; | 107 return 0; |
108 } | 108 } |
109 | 109 |
110 static void flip(AVCodecContext *avctx, AVPicture * picture){ | 110 static void flip(AVCodecContext *avctx, AVPicture * picture){ |
111 if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[1]==0){ | 111 if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[1]==0){ |
124 AVPicture * picture = (AVPicture *) data; | 124 AVPicture * picture = (AVPicture *) data; |
125 | 125 |
126 /* Early out without copy if packet size == frame size */ | 126 /* Early out without copy if packet size == frame size */ |
127 if (buf_size == context->length && context->p == context->buffer) { | 127 if (buf_size == context->length && context->p == context->buffer) { |
128 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); | 128 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); |
129 flip(avctx, picture); | 129 flip(avctx, picture); |
130 *data_size = sizeof(AVPicture); | 130 *data_size = sizeof(AVPicture); |
131 return buf_size; | 131 return buf_size; |
132 } | 132 } |
133 | 133 |
134 bytesNeeded = context->length - (context->p - context->buffer); | 134 bytesNeeded = context->length - (context->p - context->buffer); |
139 } | 139 } |
140 | 140 |
141 memcpy(context->p, buf, bytesNeeded); | 141 memcpy(context->p, buf, bytesNeeded); |
142 context->p = context->buffer; | 142 context->p = context->buffer; |
143 avpicture_fill(picture, context->buffer, avctx->pix_fmt, avctx->width, avctx->height); | 143 avpicture_fill(picture, context->buffer, avctx->pix_fmt, avctx->width, avctx->height); |
144 flip(avctx, picture); | 144 flip(avctx, picture); |
145 *data_size = sizeof(AVPicture); | 145 *data_size = sizeof(AVPicture); |
146 return bytesNeeded; | 146 return bytesNeeded; |
147 } | 147 } |
148 | 148 |
149 static int raw_close_decoder(AVCodecContext *avctx) | 149 static int raw_close_decoder(AVCodecContext *avctx) |
150 { | 150 { |
151 RawVideoContext *context = avctx->priv_data; | 151 RawVideoContext *context = avctx->priv_data; |
152 | 152 |
153 av_freep(&context->buffer); | 153 av_freep(&context->buffer); |
154 return 0; | 154 return 0; |
155 } | 155 } |
156 | 156 |
157 /* RAW Encoder Implementation */ | 157 /* RAW Encoder Implementation */ |