#include "avcodec.h"#include "dsputil.h"#include "bitstream.h"#include "bytestream.h"Go to the source code of this file.
Data Structures | |
| struct | CFrameBuffer |
| struct | FourXContext |
Defines | |
| #define | BLOCK_TYPE_VLC_BITS 5 |
| #define | ACDC_VLC_BITS 9 |
| #define | CFRAME_BUFFER_COUNT 100 |
| #define | FIX_1_082392200 70936 |
| #define | FIX_1_414213562 92682 |
| #define | FIX_1_847759065 121095 |
| #define | FIX_2_613125930 171254 |
| #define | MULTIPLY(var, const) (((var)*(const)) >> 16) |
Functions | |
| static void | idct (DCTELEM block[64]) |
| static av_cold void | init_vlcs (FourXContext *f) |
| static void | init_mv (FourXContext *f) |
| static void | mcdc (uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, int dc) |
| static void | decode_p_block (FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride) |
| static int | decode_p_frame (FourXContext *f, const uint8_t *buf, int length) |
| static int | decode_i_block (FourXContext *f, DCTELEM *block) |
| static void | idct_put (FourXContext *f, int x, int y) |
| static int | decode_i_mb (FourXContext *f) |
| static const uint8_t * | read_huffman_tables (FourXContext *f, const uint8_t *const buf) |
| static int | mix (int c0, int c1) |
| static int | decode_i2_frame (FourXContext *f, const uint8_t *buf, int length) |
| static int | decode_i_frame (FourXContext *f, const uint8_t *buf, int length) |
| static int | decode_frame (AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) |
| static void | common_init (AVCodecContext *avctx) |
| static av_cold int | decode_init (AVCodecContext *avctx) |
| static av_cold int | decode_end (AVCodecContext *avctx) |
Variables | |
| static const uint8_t | block_type_tab [2][4][8][2] |
| static const uint8_t | size2index [4][4] |
| static const int8_t | mv [256][2] |
| static const uint8_t | dequant_table [64] |
| static VLC | block_type_vlc [2][4] |
| AVCodec | fourxm_decoder |
| #define ACDC_VLC_BITS 9 |
Definition at line 36 of file libavcodec/4xm.c.
Referenced by decode_i_block(), decode_i_frame(), and read_huffman_tables().
| #define BLOCK_TYPE_VLC_BITS 5 |
| #define CFRAME_BUFFER_COUNT 100 |
| #define FIX_1_082392200 70936 |
| #define FIX_1_414213562 92682 |
| #define FIX_1_847759065 121095 |
Definition at line 149 of file libavcodec/4xm.c.
Referenced by ff_fdct248_islow(), ff_jpeg_fdct_islow(), idct(), j_rev_dct(), j_rev_dct4(), and row_fdct().
| #define FIX_2_613125930 171254 |
| #define MULTIPLY | ( | var, | |||
| const | ) | (((var)*(const)) >> 16) |
Definition at line 152 of file libavcodec/4xm.c.
Referenced by fdct_ifast(), fdct_ifast248(), ff_fdct248_islow(), ff_jpeg_fdct_islow(), idct(), j_rev_dct(), j_rev_dct4(), and row_fdct().
| static void common_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 787 of file libavcodec/4xm.c.
References FourXContext::avctx, FourXContext::dsp, dsputil_init(), and AVCodecContext::priv_data.
Referenced by decode_init(), encode_init(), and ff_msmpeg4_decode_init().
00787 { 00788 FourXContext * const f = avctx->priv_data; 00789 00790 dsputil_init(&f->dsp, avctx); 00791 00792 f->avctx= avctx; 00793 }
| static av_cold int decode_end | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 814 of file libavcodec/4xm.c.
References CFrameBuffer::allocated_size, av_freep(), FourXContext::bitstream_buffer, FourXContext::bitstream_buffer_size, CFRAME_BUFFER_COUNT, FourXContext::cfrm, CFrameBuffer::data, free_vlc(), FourXContext::pre_vlc, and AVCodecContext::priv_data.
00814 { 00815 FourXContext * const f = avctx->priv_data; 00816 int i; 00817 00818 av_freep(&f->bitstream_buffer); 00819 f->bitstream_buffer_size=0; 00820 for(i=0; i<CFRAME_BUFFER_COUNT; i++){ 00821 av_freep(&f->cfrm[i].data); 00822 f->cfrm[i].allocated_size= 0; 00823 } 00824 free_vlc(&f->pre_vlc); 00825 00826 return 0; 00827 }
| static int decode_frame | ( | AVCodecContext * | avctx, | |
| void * | data, | |||
| int * | data_size, | |||
| const uint8_t * | buf, | |||
| int | buf_size | |||
| ) | [static] |
Definition at line 677 of file libavcodec/4xm.c.
References CFrameBuffer::allocated_size, av_fast_realloc(), av_log(), AV_LOG_ERROR, AV_RL32, FourXContext::avctx, CFRAME_BUFFER_COUNT, FourXContext::cfrm, CODEC_FLAG_EMU_EDGE, AVCodecContext::coded_frame, FourXContext::current_picture, CFrameBuffer::data, decode_i2_frame(), decode_i_frame(), decode_p_frame(), emms_c, ff_get_fourcc(), FF_I_TYPE, FF_INPUT_BUFFER_PADDING_SIZE, FF_P_TYPE, AVCodecContext::flags, AVCodecContext::frame_number, AVCodecContext::get_buffer, CFrameBuffer::id, FourXContext::last_picture, picture, AVCodecContext::priv_data, AVCodecContext::release_buffer, and CFrameBuffer::size.
Referenced by flac_decode_frame(), and nut_read_packet().
00680 { 00681 FourXContext * const f = avctx->priv_data; 00682 AVFrame *picture = data; 00683 AVFrame *p, temp; 00684 int i, frame_4cc, frame_size; 00685 00686 frame_4cc= AV_RL32(buf); 00687 if(buf_size != AV_RL32(buf+4)+8 || buf_size < 20){ 00688 av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n", buf_size, AV_RL32(buf+4)); 00689 } 00690 00691 if(frame_4cc == ff_get_fourcc("cfrm")){ 00692 int free_index=-1; 00693 const int data_size= buf_size - 20; 00694 const int id= AV_RL32(buf+12); 00695 const int whole_size= AV_RL32(buf+16); 00696 CFrameBuffer *cfrm; 00697 00698 for(i=0; i<CFRAME_BUFFER_COUNT; i++){ 00699 if(f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number) 00700 av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n", f->cfrm[i].id); 00701 } 00702 00703 for(i=0; i<CFRAME_BUFFER_COUNT; i++){ 00704 if(f->cfrm[i].id == id) break; 00705 if(f->cfrm[i].size == 0 ) free_index= i; 00706 } 00707 00708 if(i>=CFRAME_BUFFER_COUNT){ 00709 i= free_index; 00710 f->cfrm[i].id= id; 00711 } 00712 cfrm= &f->cfrm[i]; 00713 00714 cfrm->data= av_fast_realloc(cfrm->data, &cfrm->allocated_size, cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE); 00715 if(!cfrm->data){ //explicit check needed as memcpy below might not catch a NULL 00716 av_log(f->avctx, AV_LOG_ERROR, "realloc falure"); 00717 return -1; 00718 } 00719 00720 memcpy(cfrm->data + cfrm->size, buf+20, data_size); 00721 cfrm->size += data_size; 00722 00723 if(cfrm->size >= whole_size){ 00724 buf= cfrm->data; 00725 frame_size= cfrm->size; 00726 00727 if(id != avctx->frame_number){ 00728 av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %d\n", id, avctx->frame_number); 00729 } 00730 00731 cfrm->size= cfrm->id= 0; 00732 frame_4cc= ff_get_fourcc("pfrm"); 00733 }else 00734 return buf_size; 00735 }else{ 00736 buf= buf + 12; 00737 frame_size= buf_size - 12; 00738 } 00739 00740 temp= f->current_picture; 00741 f->current_picture= f->last_picture; 00742 f->last_picture= temp; 00743 00744 p= &f->current_picture; 00745 avctx->coded_frame= p; 00746 00747 avctx->flags |= CODEC_FLAG_EMU_EDGE; // alternatively we would have to use our own buffer management 00748 00749 if(p->data[0]) 00750 avctx->release_buffer(avctx, p); 00751 00752 p->reference= 1; 00753 if(avctx->get_buffer(avctx, p) < 0){ 00754 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); 00755 return -1; 00756 } 00757 00758 if(frame_4cc == ff_get_fourcc("ifr2")){ 00759 p->pict_type= FF_I_TYPE; 00760 if(decode_i2_frame(f, buf-4, frame_size) < 0) 00761 return -1; 00762 }else if(frame_4cc == ff_get_fourcc("ifrm")){ 00763 p->pict_type= FF_I_TYPE; 00764 if(decode_i_frame(f, buf, frame_size) < 0) 00765 return -1; 00766 }else if(frame_4cc == ff_get_fourcc("pfrm") || frame_4cc == ff_get_fourcc("pfr2")){ 00767 p->pict_type= FF_P_TYPE; 00768 if(decode_p_frame(f, buf, frame_size) < 0) 00769 return -1; 00770 }else if(frame_4cc == ff_get_fourcc("snd_")){ 00771 av_log(avctx, AV_LOG_ERROR, "ignoring snd_ chunk length:%d\n", buf_size); 00772 }else{ 00773 av_log(avctx, AV_LOG_ERROR, "ignoring unknown chunk length:%d\n", buf_size); 00774 } 00775 00776 p->key_frame= p->pict_type == FF_I_TYPE; 00777 00778 *picture= *p; 00779 *data_size = sizeof(AVPicture); 00780 00781 emms_c(); 00782 00783 return buf_size; 00784 }
| static int decode_i2_frame | ( | FourXContext * | f, | |
| const uint8_t * | buf, | |||
| int | length | |||
| ) | [static] |
Definition at line 595 of file libavcodec/4xm.c.
References av_log(), AV_LOG_ERROR, FourXContext::avctx, bits, FourXContext::current_picture, AVCodecContext::height, height, mix(), NULL, stride, AVCodecContext::width, and width.
Referenced by decode_frame().
00595 { 00596 int x, y, x2, y2; 00597 const int width= f->avctx->width; 00598 const int height= f->avctx->height; 00599 uint16_t *dst= (uint16_t*)f->current_picture.data[0]; 00600 const int stride= f->current_picture.linesize[0]>>1; 00601 00602 for(y=0; y<height; y+=16){ 00603 for(x=0; x<width; x+=16){ 00604 unsigned int color[4], bits; 00605 memset(color, 0, sizeof(color)); 00606 //warning following is purely guessed ... 00607 color[0]= bytestream_get_le16(&buf); 00608 color[1]= bytestream_get_le16(&buf); 00609 00610 if(color[0]&0x8000) av_log(NULL, AV_LOG_ERROR, "unk bit 1\n"); 00611 if(color[1]&0x8000) av_log(NULL, AV_LOG_ERROR, "unk bit 2\n"); 00612 00613 color[2]= mix(color[0], color[1]); 00614 color[3]= mix(color[1], color[0]); 00615 00616 bits= bytestream_get_le32(&buf); 00617 for(y2=0; y2<16; y2++){ 00618 for(x2=0; x2<16; x2++){ 00619 int index= 2*(x2>>2) + 8*(y2>>2); 00620 dst[y2*stride+x2]= color[(bits>>index)&3]; 00621 } 00622 } 00623 dst+=16; 00624 } 00625 dst += 16*stride - width; 00626 } 00627 00628 return 0; 00629 }
| static int decode_i_block | ( | FourXContext * | f, | |
| DCTELEM * | block | |||
| ) | [static] |
decode block and dequantize. Note this is almost identical to MJPEG.
Definition at line 410 of file libavcodec/4xm.c.
References ACDC_VLC_BITS, av_log(), AV_LOG_ERROR, FourXContext::avctx, dequant_table, ff_zigzag_direct, FourXContext::gb, get_vlc2(), get_xbits(), FourXContext::last_dc, level, FourXContext::pre_gb, FourXContext::pre_vlc, and VLC::table.
Referenced by decode_i_mb().
00410 { 00411 int code, i, j, level, val; 00412 00413 /* DC coef */ 00414 val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); 00415 if (val>>4){ 00416 av_log(f->avctx, AV_LOG_ERROR, "error dc run != 0\n"); 00417 } 00418 00419 if(val) 00420 val = get_xbits(&f->gb, val); 00421 00422 val = val * dequant_table[0] + f->last_dc; 00423 f->last_dc = 00424 block[0] = val; 00425 /* AC coefs */ 00426 i = 1; 00427 for(;;) { 00428 code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); 00429 00430 /* EOB */ 00431 if (code == 0) 00432 break; 00433 if (code == 0xf0) { 00434 i += 16; 00435 } else { 00436 level = get_xbits(&f->gb, code & 0xf); 00437 i += code >> 4; 00438 if (i >= 64) { 00439 av_log(f->avctx, AV_LOG_ERROR, "run %d oveflow\n", i); 00440 return 0; 00441 } 00442 00443 j= ff_zigzag_direct[i]; 00444 block[j] = level * dequant_table[j]; 00445 i++; 00446 if (i >= 64) 00447 break; 00448 } 00449 } 00450 00451 return 0; 00452 }
| static int decode_i_frame | ( | FourXContext * | f, | |
| const uint8_t * | buf, | |||
| int | length | |||
| ) | [static] |
Definition at line 631 of file libavcodec/4xm.c.
References ACDC_VLC_BITS, av_fast_realloc(), av_log(), AV_LOG_ERROR, AV_RL32, av_unused, FourXContext::avctx, FourXContext::bitstream_buffer, FourXContext::bitstream_buffer_size, DSPContext::bswap_buf, FourXContext::current_picture, decode_i_mb(), FourXContext::dsp, FF_INPUT_BUFFER_PADDING_SIZE, FourXContext::gb, get_vlc2(), AVCodecContext::height, height, idct_put(), init_get_bits(), FourXContext::last_dc, FourXContext::pre_gb, FourXContext::pre_vlc, read_huffman_tables(), stride, VLC::table, AVCodecContext::width, and width.
Referenced by decode_frame().
00631 { 00632 int x, y; 00633 const int width= f->avctx->width; 00634 const int height= f->avctx->height; 00635 uint16_t *dst= (uint16_t*)f->current_picture.data[0]; 00636 const int stride= f->current_picture.linesize[0]>>1; 00637 const unsigned int bitstream_size= AV_RL32(buf); 00638 const int token_count av_unused = AV_RL32(buf + bitstream_size + 8); 00639 unsigned int prestream_size= 4*AV_RL32(buf + bitstream_size + 4); 00640 const uint8_t *prestream= buf + bitstream_size + 12; 00641 00642 if(prestream_size + bitstream_size + 12 != length 00643 || bitstream_size > (1<<26) 00644 || prestream_size > (1<<26)){ 00645 av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", prestream_size, bitstream_size, length); 00646 return -1; 00647 } 00648 00649 prestream= read_huffman_tables(f, prestream); 00650 00651 init_get_bits(&f->gb, buf + 4, 8*bitstream_size); 00652 00653 prestream_size= length + buf - prestream; 00654 00655 f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE); 00656 f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (const uint32_t*)prestream, prestream_size/4); 00657 init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size); 00658 00659 f->last_dc= 0*128*8*8; 00660 00661 for(y=0; y<height; y+=16){ 00662 for(x=0; x<width; x+=16){ 00663 if(decode_i_mb(f) < 0) 00664 return -1; 00665 00666 idct_put(f, x, y); 00667 } 00668 dst += 16*stride; 00669 } 00670 00671 if(get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3) != 256) 00672 av_log(f->avctx, AV_LOG_ERROR, "end mismatch\n"); 00673 00674 return 0; 00675 }
| static int decode_i_mb | ( | FourXContext * | f | ) | [static] |
Definition at line 498 of file libavcodec/4xm.c.
References DSPContext::clear_blocks, decode_i_block(), and FourXContext::dsp.
Referenced by decode_i_frame().
00498 { 00499 int i; 00500 00501 f->dsp.clear_blocks(f->block[0]); 00502 00503 for(i=0; i<6; i++){ 00504 if(decode_i_block(f, f->block[i]) < 0) 00505 return -1; 00506 } 00507 00508 return 0; 00509 }
| static av_cold int decode_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 795 of file libavcodec/4xm.c.
References av_log(), AV_LOG_ERROR, AV_RL32, common_init(), AVCodecContext::extradata, AVCodecContext::extradata_size, init_vlcs(), AVCodecContext::pix_fmt, PIX_FMT_RGB555, PIX_FMT_RGB565, AVCodecContext::priv_data, and FourXContext::version.
00795 { 00796 FourXContext * const f = avctx->priv_data; 00797 00798 if(avctx->extradata_size != 4 || !avctx->extradata) { 00799 av_log(avctx, AV_LOG_ERROR, "extradata wrong or missing\n"); 00800 return 1; 00801 } 00802 00803 f->version= AV_RL32(avctx->extradata)>>16; 00804 common_init(avctx); 00805 init_vlcs(f); 00806 00807 if(f->version>2) avctx->pix_fmt= PIX_FMT_RGB565; 00808 else avctx->pix_fmt= PIX_FMT_RGB555; 00809 00810 return 0; 00811 }
| static void decode_p_block | ( | FourXContext * | f, | |
| uint16_t * | dst, | |||
| uint16_t * | src, | |||
| int | log2w, | |||
| int | log2h, | |||
| int | stride | |||
| ) | [static] |
Definition at line 300 of file libavcodec/4xm.c.
References av_log(), AV_LOG_ERROR, FourXContext::avctx, block_type_vlc, BLOCK_TYPE_VLC_BITS, FourXContext::bytestream, FourXContext::gb, get_vlc2(), AVCodecContext::height, FourXContext::last_picture, le2me_16, mcdc(), FourXContext::mv, size2index, VLC::table, FourXContext::version, and FourXContext::wordstream.
Referenced by decode_p_frame().
00300 { 00301 const int index= size2index[log2h][log2w]; 00302 const int h= 1<<log2h; 00303 int code= get_vlc2(&f->gb, block_type_vlc[1-(f->version>1)][index].table, BLOCK_TYPE_VLC_BITS, 1); 00304 uint16_t *start= (uint16_t*)f->last_picture.data[0]; 00305 uint16_t *end= start + stride*(f->avctx->height-h+1) - (1<<log2w); 00306 00307 assert(code>=0 && code<=6); 00308 00309 if(code == 0){ 00310 src += f->mv[ *f->bytestream++ ]; 00311 if(start > src || src > end){ 00312 av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); 00313 return; 00314 } 00315 mcdc(dst, src, log2w, h, stride, 1, 0); 00316 }else if(code == 1){ 00317 log2h--; 00318 decode_p_block(f, dst , src , log2w, log2h, stride); 00319 decode_p_block(f, dst + (stride<<log2h), src + (stride<<log2h), log2w, log2h, stride); 00320 }else if(code == 2){ 00321 log2w--; 00322 decode_p_block(f, dst , src , log2w, log2h, stride); 00323 decode_p_block(f, dst + (1<<log2w), src + (1<<log2w), log2w, log2h, stride); 00324 }else if(code == 3 && f->version<2){ 00325 mcdc(dst, src, log2w, h, stride, 1, 0); 00326 }else if(code == 4){ 00327 src += f->mv[ *f->bytestream++ ]; 00328 if(start > src || src > end){ 00329 av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); 00330 return; 00331 } 00332 mcdc(dst, src, log2w, h, stride, 1, le2me_16(*f->wordstream++)); 00333 }else if(code == 5){ 00334 mcdc(dst, src, log2w, h, stride, 0, le2me_16(*f->wordstream++)); 00335 }else if(code == 6){ 00336 if(log2w){ 00337 dst[0] = le2me_16(*f->wordstream++); 00338 dst[1] = le2me_16(*f->wordstream++); 00339 }else{ 00340 dst[0 ] = le2me_16(*f->wordstream++); 00341 dst[stride] = le2me_16(*f->wordstream++); 00342 } 00343 } 00344 }
| static int decode_p_frame | ( | FourXContext * | f, | |
| const uint8_t * | buf, | |||
| int | length | |||
| ) | [static] |
Definition at line 346 of file libavcodec/4xm.c.
References av_fast_realloc(), av_log(), AV_LOG_ERROR, AV_RL16, AV_RL32, FourXContext::avctx, FourXContext::bitstream_buffer, FourXContext::bitstream_buffer_size, DSPContext::bswap_buf, FourXContext::bytestream, FourXContext::current_picture, decode_p_block(), FourXContext::dsp, FF_INPUT_BUFFER_PADDING_SIZE, FFMAX, FourXContext::gb, get_bits_count(), AVCodecContext::height, height, init_get_bits(), init_mv(), FourXContext::last_picture, src, stride, FourXContext::version, AVCodecContext::width, width, and FourXContext::wordstream.
Referenced by decode_frame().
00346 { 00347 int x, y; 00348 const int width= f->avctx->width; 00349 const int height= f->avctx->height; 00350 uint16_t *src= (uint16_t*)f->last_picture.data[0]; 00351 uint16_t *dst= (uint16_t*)f->current_picture.data[0]; 00352 const int stride= f->current_picture.linesize[0]>>1; 00353 unsigned int bitstream_size, bytestream_size, wordstream_size, extra; 00354 00355 if(f->version>1){ 00356 extra=20; 00357 bitstream_size= AV_RL32(buf+8); 00358 wordstream_size= AV_RL32(buf+12); 00359 bytestream_size= AV_RL32(buf+16); 00360 }else{ 00361 extra=0; 00362 bitstream_size = AV_RL16(buf-4); 00363 wordstream_size= AV_RL16(buf-2); 00364 bytestream_size= FFMAX(length - bitstream_size - wordstream_size, 0); 00365 } 00366 00367 if(bitstream_size+ bytestream_size+ wordstream_size + extra != length 00368 || bitstream_size > (1<<26) 00369 || bytestream_size > (1<<26) 00370 || wordstream_size > (1<<26) 00371 ){ 00372 av_log(f->avctx, AV_LOG_ERROR, "lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size, 00373 bitstream_size+ bytestream_size+ wordstream_size - length); 00374 return -1; 00375 } 00376 00377 f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE); 00378 f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (const uint32_t*)(buf + extra), bitstream_size/4); 00379 init_get_bits(&f->gb, f->bitstream_buffer, 8*bitstream_size); 00380 00381 f->wordstream= (const uint16_t*)(buf + extra + bitstream_size); 00382 f->bytestream= buf + extra + bitstream_size + wordstream_size; 00383 00384 init_mv(f); 00385 00386 for(y=0; y<height; y+=8){ 00387 for(x=0; x<width; x+=8){ 00388 decode_p_block(f, dst + x, src + x, 3, 3, stride); 00389 } 00390 src += 8*stride; 00391 dst += 8*stride; 00392 } 00393 00394 if( bitstream_size != (get_bits_count(&f->gb)+31)/32*4 00395 || (((const char*)f->wordstream - (const char*)buf + 2)&~2) != extra + bitstream_size + wordstream_size 00396 || (((const char*)f->bytestream - (const char*)buf + 3)&~3) != extra + bitstream_size + wordstream_size + bytestream_size) 00397 av_log(f->avctx, AV_LOG_ERROR, " %d %td %td bytes left\n", 00398 bitstream_size - (get_bits_count(&f->gb)+31)/32*4, 00399 -(((const char*)f->bytestream - (const char*)buf + 3)&~3) + (extra + bitstream_size + wordstream_size + bytestream_size), 00400 -(((const char*)f->wordstream - (const char*)buf + 2)&~2) + (extra + bitstream_size + wordstream_size) 00401 ); 00402 00403 return 0; 00404 }
| static void idct | ( | DCTELEM | block[64] | ) | [static] |
Definition at line 154 of file libavcodec/4xm.c.
References FIX_1_082392200, FIX_1_414213562, FIX_1_847759065, FIX_2_613125930, and MULTIPLY.
00154 { 00155 int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; 00156 int tmp10, tmp11, tmp12, tmp13; 00157 int z5, z10, z11, z12, z13; 00158 int i; 00159 int temp[64]; 00160 00161 for(i=0; i<8; i++){ 00162 tmp10 = block[8*0 + i] + block[8*4 + i]; 00163 tmp11 = block[8*0 + i] - block[8*4 + i]; 00164 00165 tmp13 = block[8*2 + i] + block[8*6 + i]; 00166 tmp12 = MULTIPLY(block[8*2 + i] - block[8*6 + i], FIX_1_414213562) - tmp13; 00167 00168 tmp0 = tmp10 + tmp13; 00169 tmp3 = tmp10 - tmp13; 00170 tmp1 = tmp11 + tmp12; 00171 tmp2 = tmp11 - tmp12; 00172 00173 z13 = block[8*5 + i] + block[8*3 + i]; 00174 z10 = block[8*5 + i] - block[8*3 + i]; 00175 z11 = block[8*1 + i] + block[8*7 + i]; 00176 z12 = block[8*1 + i] - block[8*7 + i]; 00177 00178 tmp7 = z11 + z13; 00179 tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); 00180 00181 z5 = MULTIPLY(z10 + z12, FIX_1_847759065); 00182 tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; 00183 tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; 00184 00185 tmp6 = tmp12 - tmp7; 00186 tmp5 = tmp11 - tmp6; 00187 tmp4 = tmp10 + tmp5; 00188 00189 temp[8*0 + i] = tmp0 + tmp7; 00190 temp[8*7 + i] = tmp0 - tmp7; 00191 temp[8*1 + i] = tmp1 + tmp6; 00192 temp[8*6 + i] = tmp1 - tmp6; 00193 temp[8*2 + i] = tmp2 + tmp5; 00194 temp[8*5 + i] = tmp2 - tmp5; 00195 temp[8*4 + i] = tmp3 + tmp4; 00196 temp[8*3 + i] = tmp3 - tmp4; 00197 } 00198 00199 for(i=0; i<8*8; i+=8){ 00200 tmp10 = temp[0 + i] + temp[4 + i]; 00201 tmp11 = temp[0 + i] - temp[4 + i]; 00202 00203 tmp13 = temp[2 + i] + temp[6 + i]; 00204 tmp12 = MULTIPLY(temp[2 + i] - temp[6 + i], FIX_1_414213562) - tmp13; 00205 00206 tmp0 = tmp10 + tmp13; 00207 tmp3 = tmp10 - tmp13; 00208 tmp1 = tmp11 + tmp12; 00209 tmp2 = tmp11 - tmp12; 00210 00211 z13 = temp[5 + i] + temp[3 + i]; 00212 z10 = temp[5 + i] - temp[3 + i]; 00213 z11 = temp[1 + i] + temp[7 + i]; 00214 z12 = temp[1 + i] - temp[7 + i]; 00215 00216 tmp7 = z11 + z13; 00217 tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); 00218 00219 z5 = MULTIPLY(z10 + z12, FIX_1_847759065); 00220 tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; 00221 tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; 00222 00223 tmp6 = tmp12 - tmp7; 00224 tmp5 = tmp11 - tmp6; 00225 tmp4 = tmp10 + tmp5; 00226 00227 block[0 + i] = (tmp0 + tmp7)>>6; 00228 block[7 + i] = (tmp0 - tmp7)>>6; 00229 block[1 + i] = (tmp1 + tmp6)>>6; 00230 block[6 + i] = (tmp1 - tmp6)>>6; 00231 block[2 + i] = (tmp2 + tmp5)>>6; 00232 block[5 + i] = (tmp2 - tmp5)>>6; 00233 block[4 + i] = (tmp3 + tmp4)>>6; 00234 block[3 + i] = (tmp3 - tmp4)>>6; 00235 } 00236 }
| static void idct_put | ( | FourXContext * | f, | |
| int | x, | |||
| int | y | |||
| ) | [inline, static] |
Definition at line 454 of file libavcodec/4xm.c.
References FourXContext::avctx, CODEC_FLAG_GRAY, FourXContext::current_picture, AVCodecContext::flags, idct, and stride.
Referenced by decode_frame(), decode_i_frame(), dsputil_init_sh4(), and dv_decode_video_segment().
00454 { 00455 DCTELEM (*block)[64]= f->block; 00456 int stride= f->current_picture.linesize[0]>>1; 00457 int i; 00458 uint16_t *dst = ((uint16_t*)f->current_picture.data[0]) + y * stride + x; 00459 00460 for(i=0; i<4; i++){ 00461 block[i][0] += 0x80*8*8; 00462 idct(block[i]); 00463 } 00464 00465 if(!(f->avctx->flags&CODEC_FLAG_GRAY)){ 00466 for(i=4; i<6; i++) idct(block[i]); 00467 } 00468 00469 /* Note transform is: 00470 y= ( 1b + 4g + 2r)/14 00471 cb=( 3b - 2g - 1r)/14 00472 cr=(-1b - 4g + 5r)/14 00473 */ 00474 for(y=0; y<8; y++){ 00475 for(x=0; x<8; x++){ 00476 DCTELEM *temp= block[(x>>2) + 2*(y>>2)] + 2*(x&3) + 2*8*(y&3); //FIXME optimize 00477 int cb= block[4][x + 8*y]; 00478 int cr= block[5][x + 8*y]; 00479 int cg= (cb + cr)>>1; 00480 int y; 00481 00482 cb+=cb; 00483 00484 y = temp[0]; 00485 dst[0 ]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8); 00486 y = temp[1]; 00487 dst[1 ]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8); 00488 y = temp[8]; 00489 dst[ stride]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8); 00490 y = temp[9]; 00491 dst[1+stride]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8); 00492 dst += 2; 00493 } 00494 dst += 2*stride - 2*8; 00495 } 00496 }
| static void init_mv | ( | FourXContext * | f | ) | [static] |
Definition at line 248 of file libavcodec/4xm.c.
References FourXContext::current_picture, mv, FourXContext::mv, and FourXContext::version.
Referenced by decode_p_frame().
00248 { 00249 int i; 00250 00251 for(i=0; i<256; i++){ 00252 if(f->version>1) 00253 f->mv[i] = mv[i][0] + mv[i][1] *f->current_picture.linesize[0]/2; 00254 else 00255 f->mv[i] = (i&15) - 8 + ((i>>4)-8)*f->current_picture.linesize[0]/2; 00256 } 00257 }
| static av_cold void init_vlcs | ( | FourXContext * | f | ) | [static] |
Definition at line 238 of file libavcodec/4xm.c.
References block_type_tab, block_type_vlc, BLOCK_TYPE_VLC_BITS, and init_vlc.
Referenced by decode_init(), and mpeg_decode_init().
00238 { 00239 int i; 00240 00241 for(i=0; i<8; i++){ 00242 init_vlc(&block_type_vlc[0][i], BLOCK_TYPE_VLC_BITS, 7, 00243 &block_type_tab[0][i][0][1], 2, 1, 00244 &block_type_tab[0][i][0][0], 2, 1, 1); 00245 } 00246 }
| static void mcdc | ( | uint16_t * | dst, | |
| uint16_t * | src, | |||
| int | log2w, | |||
| int | h, | |||
| int | stride, | |||
| int | scale, | |||
| int | dc | |||
| ) | [inline, static] |
Definition at line 259 of file libavcodec/4xm.c.
Referenced by decode_p_block().
00259 { 00260 int i; 00261 dc*= 0x10001; 00262 00263 switch(log2w){ 00264 case 0: 00265 for(i=0; i<h; i++){ 00266 dst[0] = scale*src[0] + dc; 00267 if(scale) src += stride; 00268 dst += stride; 00269 } 00270 break; 00271 case 1: 00272 for(i=0; i<h; i++){ 00273 ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc; 00274 if(scale) src += stride; 00275 dst += stride; 00276 } 00277 break; 00278 case 2: 00279 for(i=0; i<h; i++){ 00280 ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc; 00281 ((uint32_t*)dst)[1] = scale*((uint32_t*)src)[1] + dc; 00282 if(scale) src += stride; 00283 dst += stride; 00284 } 00285 break; 00286 case 3: 00287 for(i=0; i<h; i++){ 00288 ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc; 00289 ((uint32_t*)dst)[1] = scale*((uint32_t*)src)[1] + dc; 00290 ((uint32_t*)dst)[2] = scale*((uint32_t*)src)[2] + dc; 00291 ((uint32_t*)dst)[3] = scale*((uint32_t*)src)[3] + dc; 00292 if(scale) src += stride; 00293 dst += stride; 00294 } 00295 break; 00296 default: assert(0); 00297 } 00298 }
| static int mix | ( | int | c0, | |
| int | c1 | |||
| ) | [static] |
Definition at line 588 of file libavcodec/4xm.c.
Referenced by decode_i2_frame().
00588 { 00589 int blue = 2*(c0&0x001F) + (c1&0x001F); 00590 int green= (2*(c0&0x03E0) + (c1&0x03E0))>>5; 00591 int red = 2*(c0>>10) + (c1>>10); 00592 return red/3*1024 + green/3*32 + blue/3; 00593 }
| static const uint8_t* read_huffman_tables | ( | FourXContext * | f, | |
| const uint8_t *const | buf | |||
| ) | [static] |
Definition at line 511 of file libavcodec/4xm.c.
References ACDC_VLC_BITS, av_log(), AV_LOG_ERROR, FourXContext::avctx, bits, init_vlc, len, and FourXContext::pre_vlc.
Referenced by decode_i_frame().