comparison vc1.c @ 6304:73a8529568bd libavcodec

const
author aurel
date Fri, 01 Feb 2008 23:25:27 +0000
parents b7045a85cd7d
children 8e63d869a904
comparison
equal deleted inserted replaced
6303:d78e2ce9b088 6304:73a8529568bd
3774 } 3774 }
3775 3775
3776 /** Find VC-1 marker in buffer 3776 /** Find VC-1 marker in buffer
3777 * @return position where next marker starts or end of buffer if no marker found 3777 * @return position where next marker starts or end of buffer if no marker found
3778 */ 3778 */
3779 static av_always_inline uint8_t* find_next_marker(uint8_t *src, uint8_t *end) 3779 static av_always_inline const uint8_t* find_next_marker(const uint8_t *src, const uint8_t *end)
3780 { 3780 {
3781 uint32_t mrk = 0xFFFFFFFF; 3781 uint32_t mrk = 0xFFFFFFFF;
3782 3782
3783 if(end-src < 4) return end; 3783 if(end-src < 4) return end;
3784 while(src < end){ 3784 while(src < end){
3787 return src-4; 3787 return src-4;
3788 } 3788 }
3789 return end; 3789 return end;
3790 } 3790 }
3791 3791
3792 static av_always_inline int vc1_unescape_buffer(uint8_t *src, int size, uint8_t *dst) 3792 static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)
3793 { 3793 {
3794 int dsize = 0, i; 3794 int dsize = 0, i;
3795 3795
3796 if(size < 4){ 3796 if(size < 4){
3797 for(dsize = 0; dsize < size; dsize++) *dst++ = *src++; 3797 for(dsize = 0; dsize < size; dsize++) *dst++ = *src++;
3860 else if (count < 0) 3860 else if (count < 0)
3861 { 3861 {
3862 av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); 3862 av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
3863 } 3863 }
3864 } else { // VC1/WVC1 3864 } else { // VC1/WVC1
3865 uint8_t *start = avctx->extradata, *end = avctx->extradata + avctx->extradata_size; 3865 const uint8_t *start = avctx->extradata;
3866 uint8_t *next; int size, buf2_size; 3866 uint8_t *end = avctx->extradata + avctx->extradata_size;
3867 const uint8_t *next;
3868 int size, buf2_size;
3867 uint8_t *buf2 = NULL; 3869 uint8_t *buf2 = NULL;
3868 int seq_inited = 0, ep_inited = 0; 3870 int seq_inited = 0, ep_inited = 0;
3869 3871
3870 if(avctx->extradata_size < 16) { 3872 if(avctx->extradata_size < 16) {
3871 av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size); 3873 av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size);
3996 av_free(buf2); 3998 av_free(buf2);
3997 return -1; 3999 return -1;
3998 } 4000 }
3999 } 4001 }
4000 }else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ /* WVC1 interlaced stores both fields divided by marker */ 4002 }else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ /* WVC1 interlaced stores both fields divided by marker */
4001 uint8_t *divider; 4003 const uint8_t *divider;
4002 4004
4003 divider = find_next_marker(buf, buf + buf_size); 4005 divider = find_next_marker(buf, buf + buf_size);
4004 if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){ 4006 if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){
4005 av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n"); 4007 av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
4006 return -1; 4008 return -1;