Commit f737e760 authored by Peter Ross's avatar Peter Ross

iff decoder: reindent

Signed-off-by: 's avatarPeter Ross <pross@xvid.org>
parent 929a24ef
...@@ -566,154 +566,154 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -566,154 +566,154 @@ static int decode_frame(AVCodecContext *avctx,
switch (s->compression) { switch (s->compression) {
case 0: case 0:
if (avctx->codec_tag == MKTAG('A','C','B','M')) { if (avctx->codec_tag == MKTAG('A','C','B','M')) {
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) { if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
memset(s->frame.data[0], 0, avctx->height * s->frame.linesize[0]); memset(s->frame.data[0], 0, avctx->height * s->frame.linesize[0]);
for (plane = 0; plane < s->bpp; plane++) { for (plane = 0; plane < s->bpp; plane++) {
for(y = 0; y < avctx->height && buf < buf_end; y++ ) { for(y = 0; y < avctx->height && buf < buf_end; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane); decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane);
buf += s->planesize; buf += s->planesize;
}
} }
} } else if (s->ham) { // HAM to AV_PIX_FMT_BGR32
} else if (s->ham) { // HAM to AV_PIX_FMT_BGR32 memset(s->frame.data[0], 0, avctx->height * s->frame.linesize[0]);
memset(s->frame.data[0], 0, avctx->height * s->frame.linesize[0]); for(y = 0; y < avctx->height; y++) {
for(y = 0; y < avctx->height; y++) { uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
memset(s->ham_buf, 0, s->planesize * 8);
for (plane = 0; plane < s->bpp; plane++) {
const uint8_t * start = buf + (plane * avctx->height + y) * s->planesize;
if (start >= buf_end)
break;
decodeplane8(s->ham_buf, start, FFMIN(s->planesize, buf_end - start), plane);
}
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
} else
return unsupported(avctx);
} else if (avctx->codec_tag == MKTAG('D','E','E','P')) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int raw_width = avctx->width * (av_get_bits_per_pixel(desc) >> 3);
int x;
for(y = 0; y < avctx->height && buf < buf_end; y++ ) {
uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]]; uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
memset(s->ham_buf, 0, s->planesize * 8); memcpy(row, buf, FFMIN(raw_width, buf_end - buf));
for (plane = 0; plane < s->bpp; plane++) { buf += raw_width;
const uint8_t * start = buf + (plane * avctx->height + y) * s->planesize; if (avctx->pix_fmt == AV_PIX_FMT_BGR32) {
if (start >= buf_end) for(x = 0; x < avctx->width; x++)
break; row[4 * x + 3] = row[4 * x + 3] & 0xF0 | (row[4 * x + 3] >> 4);
decodeplane8(s->ham_buf, start, FFMIN(s->planesize, buf_end - start), plane);
} }
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
} }
} else } else if (avctx->codec_tag == MKTAG('I','L','B','M')) { // interleaved
return unsupported(avctx); if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
} else if (avctx->codec_tag == MKTAG('D','E','E','P')) { for(y = 0; y < avctx->height; y++ ) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
int raw_width = avctx->width * (av_get_bits_per_pixel(desc) >> 3); memset(row, 0, avctx->width);
int x; for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
for(y = 0; y < avctx->height && buf < buf_end; y++ ) { decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane);
uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]]; buf += s->planesize;
memcpy(row, buf, FFMIN(raw_width, buf_end - buf)); }
buf += raw_width;
if (avctx->pix_fmt == AV_PIX_FMT_BGR32) {
for(x = 0; x < avctx->width; x++)
row[4 * x + 3] = row[4 * x + 3] & 0xF0 | (row[4 * x + 3] >> 4);
}
}
} else if (avctx->codec_tag == MKTAG('I','L','B','M')) { // interleaved
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memset(row, 0, avctx->width);
for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane);
buf += s->planesize;
} }
} } else if (s->ham) { // HAM to AV_PIX_FMT_BGR32
} else if (s->ham) { // HAM to AV_PIX_FMT_BGR32 for (y = 0; y < avctx->height; y++) {
for (y = 0; y < avctx->height; y++) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; memset(s->ham_buf, 0, s->planesize * 8);
memset(s->ham_buf, 0, s->planesize * 8); for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
for (plane = 0; plane < s->bpp && buf < buf_end; plane++) { decodeplane8(s->ham_buf, buf, FFMIN(s->planesize, buf_end - buf), plane);
decodeplane8(s->ham_buf, buf, FFMIN(s->planesize, buf_end - buf), plane); buf += s->planesize;
buf += s->planesize; }
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
} }
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); } else { // AV_PIX_FMT_BGR32
} for(y = 0; y < avctx->height; y++ ) {
} else { // AV_PIX_FMT_BGR32 uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
for(y = 0; y < avctx->height; y++ ) { memset(row, 0, avctx->width << 2);
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
memset(row, 0, avctx->width << 2); decodeplane32((uint32_t *) row, buf, FFMIN(s->planesize, buf_end - buf), plane);
for (plane = 0; plane < s->bpp && buf < buf_end; plane++) { buf += s->planesize;
decodeplane32((uint32_t *) row, buf, FFMIN(s->planesize, buf_end - buf), plane); }
buf += s->planesize;
} }
} }
} else if (avctx->codec_tag == MKTAG('P','B','M',' ')) { // IFF-PBM
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height && buf_end > buf; y++ ) {
uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
memcpy(row, buf, FFMIN(avctx->width, buf_end - buf));
buf += avctx->width + (avctx->width % 2); // padding if odd
}
} else if (s->ham) { // IFF-PBM: HAM to AV_PIX_FMT_BGR32
for (y = 0; y < avctx->height && buf_end > buf; y++) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memcpy(s->ham_buf, buf, FFMIN(avctx->width, buf_end - buf));
buf += avctx->width + (avctx->width & 1); // padding if odd
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
} else
return unsupported(avctx);
} }
} else if (avctx->codec_tag == MKTAG('P','B','M',' ')) { // IFF-PBM break;
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height && buf_end > buf; y++ ) {
uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
memcpy(row, buf, FFMIN(avctx->width, buf_end - buf));
buf += avctx->width + (avctx->width % 2); // padding if odd
}
} else if (s->ham) { // IFF-PBM: HAM to AV_PIX_FMT_BGR32
for (y = 0; y < avctx->height && buf_end > buf; y++) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memcpy(s->ham_buf, buf, FFMIN(avctx->width, buf_end - buf));
buf += avctx->width + (avctx->width & 1); // padding if odd
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
} else
return unsupported(avctx);
}
break;
case 1: case 1:
if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) { if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height ; y++ ) { for(y = 0; y < avctx->height ; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memset(row, 0, avctx->width); memset(row, 0, avctx->width);
for (plane = 0; plane < s->bpp; plane++) { for (plane = 0; plane < s->bpp; plane++) {
buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end);
decodeplane8(row, s->planebuf, s->planesize, plane); decodeplane8(row, s->planebuf, s->planesize, plane);
}
} }
} } else if (avctx->bits_per_coded_sample <= 8) { //8-bit (+ mask) to AV_PIX_FMT_BGR32
} else if (avctx->bits_per_coded_sample <= 8) { //8-bit (+ mask) to AV_PIX_FMT_BGR32 for (y = 0; y < avctx->height ; y++ ) {
for (y = 0; y < avctx->height ; y++ ) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; memset(s->mask_buf, 0, avctx->width * sizeof(uint32_t));
memset(s->mask_buf, 0, avctx->width * sizeof(uint32_t)); for (plane = 0; plane < s->bpp; plane++) {
for (plane = 0; plane < s->bpp; plane++) { buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end);
buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); decodeplane32(s->mask_buf, s->planebuf, s->planesize, plane);
decodeplane32(s->mask_buf, s->planebuf, s->planesize, plane); }
lookup_pal_indicies((uint32_t *) row, s->mask_buf, s->mask_palbuf, avctx->width);
} }
lookup_pal_indicies((uint32_t *) row, s->mask_buf, s->mask_palbuf, avctx->width); } else if (s->ham) { // HAM to AV_PIX_FMT_BGR32
} for (y = 0; y < avctx->height ; y++) {
} else if (s->ham) { // HAM to AV_PIX_FMT_BGR32 uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
for (y = 0; y < avctx->height ; y++) { memset(s->ham_buf, 0, s->planesize * 8);
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; for (plane = 0; plane < s->bpp; plane++) {
memset(s->ham_buf, 0, s->planesize * 8); buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end);
for (plane = 0; plane < s->bpp; plane++) { decodeplane8(s->ham_buf, s->planebuf, s->planesize, plane);
buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); }
decodeplane8(s->ham_buf, s->planebuf, s->planesize, plane); decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
} }
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); } else { //AV_PIX_FMT_BGR32
} for(y = 0; y < avctx->height ; y++ ) {
} else { //AV_PIX_FMT_BGR32 uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
for(y = 0; y < avctx->height ; y++ ) { memset(row, 0, avctx->width << 2);
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; for (plane = 0; plane < s->bpp; plane++) {
memset(row, 0, avctx->width << 2); buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end);
for (plane = 0; plane < s->bpp; plane++) { decodeplane32((uint32_t *) row, s->planebuf, s->planesize, plane);
buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); }
decodeplane32((uint32_t *) row, s->planebuf, s->planesize, plane);
} }
} }
} else if (avctx->codec_tag == MKTAG('P','B','M',' ')) { // IFF-PBM
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height ; y++ ) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
buf += decode_byterun(row, avctx->width, buf, buf_end);
}
} else if (s->ham) { // IFF-PBM: HAM to AV_PIX_FMT_BGR32
for (y = 0; y < avctx->height ; y++) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
buf += decode_byterun(s->ham_buf, avctx->width, buf, buf_end);
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
} else
return unsupported(avctx);
} else if (avctx->codec_tag == MKTAG('D','E','E','P')) { // IFF-DEEP
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
if (av_get_bits_per_pixel(desc) == 32)
decode_deep_rle32(s->frame.data[0], buf, buf_size, avctx->width, avctx->height, s->frame.linesize[0]);
else
return unsupported(avctx);
} }
} else if (avctx->codec_tag == MKTAG('P','B','M',' ')) { // IFF-PBM
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
for(y = 0; y < avctx->height ; y++ ) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
buf += decode_byterun(row, avctx->width, buf, buf_end);
}
} else if (s->ham) { // IFF-PBM: HAM to AV_PIX_FMT_BGR32
for (y = 0; y < avctx->height ; y++) {
uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
buf += decode_byterun(s->ham_buf, avctx->width, buf, buf_end);
decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize);
}
} else
return unsupported(avctx);
} else if (avctx->codec_tag == MKTAG('D','E','E','P')) { // IFF-DEEP
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
if (av_get_bits_per_pixel(desc) == 32)
decode_deep_rle32(s->frame.data[0], buf, buf_size, avctx->width, avctx->height, s->frame.linesize[0]);
else
return unsupported(avctx);
}
break; break;
default: default:
return unsupported(avctx); return unsupported(avctx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment