Mercurial > libavcodec.hg
comparison nuv.c @ 5653:1b0c60bfae2a libavcodec
Simplify nuv: factor out LZO decompression
author | reimar |
---|---|
date | Sun, 09 Sep 2007 08:22:07 +0000 |
parents | f99e40a7155b |
children | 93a54fcfa2f4 |
comparison
equal
deleted
inserted
replaced
5652:941e5deeb2a4 | 5653:1b0c60bfae2a |
---|---|
112 } | 112 } |
113 comptype = buf[1]; | 113 comptype = buf[1]; |
114 // skip rest of the frameheader. | 114 // skip rest of the frameheader. |
115 buf = &buf[12]; | 115 buf = &buf[12]; |
116 buf_size -= 12; | 116 buf_size -= 12; |
117 if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) { | |
118 int outlen = c->decomp_size, inlen = buf_size; | |
119 if (lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) | |
120 av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | |
121 buf = c->decomp_buf; | |
122 buf_size = c->decomp_size; | |
123 } | |
117 | 124 |
118 c->pic.pict_type = FF_I_TYPE; | 125 c->pic.pict_type = FF_I_TYPE; |
119 c->pic.key_frame = 1; | 126 c->pic.key_frame = 1; |
120 // decompress/copy/whatever data | 127 // decompress/copy/whatever data |
121 switch (comptype) { | 128 switch (comptype) { |
129 case NUV_LZO: | |
122 case NUV_UNCOMPRESSED: { | 130 case NUV_UNCOMPRESSED: { |
123 int height = c->height; | 131 int height = c->height; |
124 if (buf_size < c->width * height * 3 / 2) { | 132 if (buf_size < c->width * height * 3 / 2) { |
125 av_log(avctx, AV_LOG_ERROR, "uncompressed frame too short\n"); | 133 av_log(avctx, AV_LOG_ERROR, "uncompressed frame too short\n"); |
126 height = buf_size / c->width / 3 * 2; | 134 height = buf_size / c->width / 3 * 2; |
127 } | 135 } |
128 copy_frame(&c->pic, buf, c->width, height); | 136 copy_frame(&c->pic, buf, c->width, height); |
129 break; | 137 break; |
130 } | 138 } |
139 case NUV_RTJPEG_IN_LZO: | |
131 case NUV_RTJPEG: { | 140 case NUV_RTJPEG: { |
132 rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size); | 141 rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size); |
133 break; | |
134 } | |
135 case NUV_RTJPEG_IN_LZO: { | |
136 int outlen = c->decomp_size, inlen = buf_size; | |
137 if (lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) | |
138 av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | |
139 rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, c->decomp_buf, c->decomp_size); | |
140 break; | |
141 } | |
142 case NUV_LZO: { | |
143 int outlen = c->decomp_size, inlen = buf_size; | |
144 if (lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) | |
145 av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | |
146 copy_frame(&c->pic, c->decomp_buf, c->width, c->height); | |
147 break; | 142 break; |
148 } | 143 } |
149 case NUV_BLACK: { | 144 case NUV_BLACK: { |
150 memset(c->pic.data[0], 0, c->width * c->height); | 145 memset(c->pic.data[0], 0, c->width * c->height); |
151 memset(c->pic.data[1], 128, c->width * c->height / 4); | 146 memset(c->pic.data[1], 128, c->width * c->height / 4); |