Mercurial > libavcodec.hg
annotate raw.c @ 1140:e3c231c7eb04 libavcodec
10l
author | michaelni |
---|---|
date | Mon, 17 Mar 2003 09:53:39 +0000 |
parents | 6842feb093c1 |
children | c85d33c011ab |
rev | line source |
---|---|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
1 /* |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
2 * Raw Video Codec |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
3 * Copyright (c) 2001 Fabrice Bellard. |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
4 * |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
9 * |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
14 * |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
18 */ |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
19 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
20 /** |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
21 * @file raw.c |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
22 * Raw Video Codec |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
23 */ |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
24 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
25 #include "avcodec.h" |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
26 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
27 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
28 typedef struct PixleFormatTag { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
29 int pix_fmt; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
30 unsigned int fourcc; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
31 } PixelFormatTag; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
32 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
33 const PixelFormatTag pixelFormatTags[] = { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
34 { PIX_FMT_YUV422, MKTAG('Y', '4', '2', '2') }, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
35 { -1, 0 }, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
36 }; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
37 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
38 static int findPixelFormat(unsigned int fourcc) |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
39 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
40 const PixelFormatTag * tags = pixelFormatTags; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
41 while (tags->pix_fmt >= 0) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
42 if (tags->fourcc == fourcc) |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
43 return tags->pix_fmt; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
44 tags++; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
45 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
46 return PIX_FMT_YUV420P; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
47 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
48 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
49 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
50 typedef struct RawVideoContext { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
51 unsigned char * buffer; /* block of memory for holding one frame */ |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
52 unsigned char * p; /* current position in buffer */ |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
53 int length; /* number of bytes in buffer */ |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
54 } RawVideoContext; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
55 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
56 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
57 static int raw_init(AVCodecContext *avctx) |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
58 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
59 RawVideoContext *context = avctx->priv_data; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
60 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
61 if (avctx->codec_tag) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
62 avctx->pix_fmt = findPixelFormat(avctx->codec_tag); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
63 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
64 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
65 context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
66 context->buffer = av_malloc(context->length); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
67 context->p = context->buffer; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
68 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
69 if (! context->buffer) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
70 return -1; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
71 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
72 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
73 return 0; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
74 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
75 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
76 static int raw_decode(AVCodecContext *avctx, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
77 void *data, int *data_size, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
78 uint8_t *buf, int buf_size) |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
79 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
80 RawVideoContext *context = avctx->priv_data; |
1140 | 81 int bytesNeeded; |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
82 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
83 AVPicture * picture = (AVPicture *) data; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
84 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
85 /* Early out without copy if packet size == frame size */ |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
86 if (buf_size == context->length && context->p == context->buffer) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
87 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
88 *data_size = sizeof(AVPicture); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
89 return buf_size; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
90 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
91 |
1140 | 92 bytesNeeded = context->length - (context->p - context->buffer); |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
93 if (buf_size < bytesNeeded) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
94 memcpy(context->p, buf, buf_size); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
95 context->p += buf_size; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
96 *data_size = 0; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
97 return buf_size; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
98 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
99 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
100 memcpy(context->p, buf, bytesNeeded); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
101 context->p = context->buffer; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
102 avpicture_fill(picture, context->buffer, avctx->pix_fmt, avctx->width, avctx->height); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
103 *data_size = sizeof(AVPicture); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
104 return bytesNeeded; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
105 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
106 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
107 static int raw_close(AVCodecContext *avctx) |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
108 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
109 RawVideoContext *context = avctx->priv_data; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
110 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
111 av_freep(& context->buffer); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
112 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
113 return 0; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
114 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
115 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
116 static int raw_encode(AVCodecContext *avctx, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
117 unsigned char *frame, int buf_size, void *data) |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
118 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
119 AVPicture * picture = data; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
120 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
121 unsigned char *src; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
122 unsigned char *dest = frame; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
123 int i, j; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
124 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
125 int w = avctx->width; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
126 int h = avctx->height; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
127 int size = avpicture_get_size(avctx->pix_fmt, w, h); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
128 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
129 if (size > buf_size) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
130 return -1; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
131 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
132 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
133 switch(avctx->pix_fmt) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
134 case PIX_FMT_YUV420P: |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
135 for(i=0;i<3;i++) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
136 if (i == 1) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
137 w >>= 1; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
138 h >>= 1; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
139 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
140 src = picture->data[i]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
141 for(j=0;j<h;j++) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
142 memcpy(dest, src, w); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
143 dest += w; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
144 src += picture->linesize[i]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
145 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
146 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
147 break; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
148 case PIX_FMT_YUV422P: |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
149 for(i=0;i<3;i++) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
150 if (i == 1) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
151 w >>= 1; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
152 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
153 src = picture->data[i]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
154 for(j=0;j<h;j++) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
155 memcpy(dest, src, w); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
156 dest += w; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
157 src += picture->linesize[i]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
158 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
159 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
160 break; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
161 case PIX_FMT_YUV444P: |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
162 for(i=0;i<3;i++) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
163 src = picture->data[i]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
164 for(j=0;j<h;j++) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
165 memcpy(dest, src, w); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
166 dest += w; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
167 src += picture->linesize[i]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
168 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
169 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
170 break; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
171 case PIX_FMT_YUV422: |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
172 src = picture->data[0]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
173 for(j=0;j<h;j++) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
174 memcpy(dest, src, w * 2); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
175 dest += w * 2; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
176 src += picture->linesize[0]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
177 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
178 break; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
179 case PIX_FMT_RGB24: |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
180 case PIX_FMT_BGR24: |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
181 src = picture->data[0]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
182 for(j=0;j<h;j++) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
183 memcpy(dest, src, w * 3); |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
184 dest += w * 3; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
185 src += picture->linesize[0]; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
186 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
187 break; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
188 default: |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
189 return -1; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
190 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
191 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
192 return size; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
193 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
194 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
195 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
196 AVCodec rawvideo_codec = { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
197 "rawvideo", |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
198 CODEC_TYPE_VIDEO, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
199 CODEC_ID_RAWVIDEO, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
200 sizeof(RawVideoContext), |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
201 raw_init, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
202 raw_encode, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
203 raw_close, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
204 raw_decode, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
205 }; |