*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
* For more information about the Id CIN format, visit:
* http://www.csse.monash.edu.au/~timf/
*
- * This video decoder outputs PAL8 colorspace data.
+ * This video decoder outputs PAL8 colorspace data. Interacting with this
+ * decoder is a little involved. During initialization, the demuxer must
+ * transmit the 65536-byte Huffman table(s) to the decoder via extradata.
+ * Then, whenever a palette change is encountered while demuxing the file,
+ * the demuxer must use the same extradata space to transmit an
+ * AVPaletteControl structure.
*
* Id CIN video is purely Huffman-coded, intraframe-only codec. It achieves
* a little more compression by exploiting the fact that adjacent pixels
unsigned char *buf;
int size;
- unsigned char palette[PALETTE_COUNT * 4];
-
hnode_t huff_nodes[256][HUF_TOKENS*2];
int num_huff_nodes[256];
/* make sure the Huffman tables make it */
if (s->avctx->extradata_size != HUFFMAN_TABLE_SIZE) {
- printf(" Id CIN video: expected extradata size of %d\n", HUFFMAN_TABLE_SIZE);
+ av_log(s->avctx, AV_LOG_ERROR, " Id CIN video: expected extradata size of %d\n", HUFFMAN_TABLE_SIZE);
return -1;
}
while(node_num >= HUF_TOKENS) {
if(!bit_pos) {
- if(dat_pos > s->size) {
- printf("Huffman decode error.\n");
+ if(dat_pos >= s->size) {
+ av_log(s->avctx, AV_LOG_ERROR, "Huffman decode error.\n");
return;
}
bit_pos = 8;
uint8_t *buf, int buf_size)
{
IdcinContext *s = (IdcinContext *)avctx->priv_data;
- AVPaletteControl *palette_control =
- (AVPaletteControl *)avctx->extradata;
- int i;
- unsigned int *palette32;
- int palette_index = 0;
- unsigned char r, g, b;
+ AVPaletteControl *palette_control = avctx->palctrl;
s->buf = buf;
s->size = buf_size;
- if (palette_control->palette_changed) {
- palette32 = (unsigned int *)s->palette;
- for (i = 0; i < PALETTE_COUNT; i++) {
- r = palette_control->palette[palette_index++] * 1;
- g = palette_control->palette[palette_index++] * 1;
- b = palette_control->palette[palette_index++] * 1;
- palette32[i] = (r << 16) | (g << 8) | (b);
- }
- palette_control->palette_changed = 0;
- }
-
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
if (avctx->get_buffer(avctx, &s->frame)) {
- printf (" Id CIN Video: get_buffer() failed\n");
+ av_log(avctx, AV_LOG_ERROR, " Id CIN Video: get_buffer() failed\n");
return -1;
}
idcin_decode_vlcs(s);
/* make the palette available on the way out */
- memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4);
+ memcpy(s->frame.data[1], palette_control->palette, PALETTE_COUNT * 4);
+ /* If palette changed inform application*/
+ if (palette_control->palette_changed) {
+ palette_control->palette_changed = 0;
+ s->frame.palette_has_changed = 1;
+ }
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;