Merge commit 'adf8227cf4e7b4fccb2ad88e1e09b6dc00dd00ed'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 5 Aug 2014 10:59:02 +0000 (12:59 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 5 Aug 2014 11:00:41 +0000 (13:00 +0200)
* commit 'adf8227cf4e7b4fccb2ad88e1e09b6dc00dd00ed':
  vc-1: Add platform-specific start code search routine to VC1DSPContext.

Conflicts:
configure
libavcodec/arm/vc1dsp_init_arm.c
libavcodec/vc1dsp.c
libavcodec/vc1dsp.h

See: 9d8ecdd8ca6d248e7439e8fdf255e39eda14e0f2
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
configure
libavcodec/Makefile
libavcodec/arm/Makefile
libavcodec/arm/vc1dsp_init_arm.c
libavcodec/vc1_parser.c
libavcodec/vc1dsp.c
libavcodec/vc1dsp.h

diff --cc configure
+++ b/configure
@@@ -2298,14 -1961,11 +2298,14 @@@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hw
  
  # parsers
  h264_parser_select="h264_decoder"
 +hevc_parser_select="hevc_decoder"
  mpegvideo_parser_select="mpegvideo"
  mpeg4video_parser_select="error_resilience h263dsp mpeg_er mpegvideo qpeldsp"
- vc1_parser_select="mpegvideo vc1_decoder"
 -vc1_parser_select="mpegvideo startcode"
++vc1_parser_select="mpegvideo startcode vc1_decoder"
  
  # external libraries
 +libaacplus_encoder_deps="libaacplus"
 +libcelt_decoder_deps="libcelt"
  libfaac_encoder_deps="libfaac"
  libfaac_encoder_select="audio_frame_queue"
  libfdk_aac_decoder_deps="libfdk_aac"
@@@ -477,8 -394,7 +477,8 @@@ OBJS-$(CONFIG_V210X_DECODER)           
  OBJS-$(CONFIG_VB_DECODER)              += vb.o
  OBJS-$(CONFIG_VBLE_DECODER)            += vble.o
  OBJS-$(CONFIG_VC1_DECODER)             += vc1dec.o vc1.o vc1data.o vc1dsp.o \
 -                                          msmpeg4dec.o msmpeg4.o msmpeg4data.o
 +                                          msmpeg4dec.o msmpeg4.o msmpeg4data.o \
-                                           wmv2dsp.o startcode.o
++                                          wmv2dsp.o
  OBJS-$(CONFIG_VCR1_DECODER)            += vcr1.o
  OBJS-$(CONFIG_VMDAUDIO_DECODER)        += vmdaudio.o
  OBJS-$(CONFIG_VMDVIDEO_DECODER)        += vmdvideo.o
Simple merge
Simple merge
@@@ -119,109 -148,15 +119,109 @@@ static int vc1_parse(AVCodecParserConte
                             const uint8_t **poutbuf, int *poutbuf_size,
                             const uint8_t *buf, int buf_size)
  {
 +    /* Here we do the searching for frame boundaries and headers at
 +     * the same time. Only a minimal amount at the start of each
 +     * header is unescaped. */
      VC1ParseContext *vpc = s->priv_data;
 -    int next;
 +    int pic_found = vpc->pc.frame_start_found;
 +    uint8_t *unesc_buffer = vpc->unesc_buffer;
 +    size_t unesc_index = vpc->unesc_index;
 +    VC1ParseSearchState search_state = vpc->search_state;
 +    int next = END_NOT_FOUND;
 +    int i = vpc->bytes_to_skip;
  
 -    if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
 -        next= buf_size;
 -    }else{
 -        next= vc1_find_frame_end(&vpc->pc, buf, buf_size);
 +    if (pic_found && buf_size == 0) {
 +        /* EOF considered as end of frame */
 +        memset(unesc_buffer + unesc_index, 0, UNESCAPED_THRESHOLD - unesc_index);
 +        vc1_extract_header(s, avctx, unesc_buffer, unesc_index);
 +        next = 0;
 +    }
 +    while (i < buf_size) {
 +        int start_code_found = 0;
 +        uint8_t b;
 +        while (i < buf_size && unesc_index < UNESCAPED_THRESHOLD) {
 +            b = buf[i++];
 +            unesc_buffer[unesc_index++] = b;
 +            if (search_state <= ONE_ZERO)
 +                search_state = b ? NO_MATCH : search_state + 1;
 +            else if (search_state == TWO_ZEROS) {
 +                if (b == 1)
 +                    search_state = ONE;
 +                else if (b > 1) {
 +                    if (b == 3)
 +                        unesc_index--; // swallow emulation prevention byte
 +                    search_state = NO_MATCH;
 +                }
 +            }
 +            else { // search_state == ONE
 +                // Header unescaping terminates early due to detection of next start code
 +                search_state = NO_MATCH;
 +                start_code_found = 1;
 +                break;
 +            }
 +        }
 +        if ((s->flags & PARSER_FLAG_COMPLETE_FRAMES) &&
 +                unesc_index >= UNESCAPED_THRESHOLD &&
 +                vpc->prev_start_code == (VC1_CODE_FRAME & 0xFF))
 +        {
 +            // No need to keep scanning the rest of the buffer for
 +            // start codes if we know it contains a complete frame and
 +            // we've already unescaped all we need of the frame header
 +            vc1_extract_header(s, avctx, unesc_buffer, unesc_index);
 +            break;
 +        }
 +        if (unesc_index >= UNESCAPED_THRESHOLD && !start_code_found) {
 +            while (i < buf_size) {
 +                if (search_state == NO_MATCH) {
-                     i += vpc->v.vc1dsp.vc1_find_start_code_candidate(buf + i, buf_size - i);
++                    i += vpc->v.vc1dsp.startcode_find_candidate(buf + i, buf_size - i);
 +                    if (i < buf_size) {
 +                        search_state = ONE_ZERO;
 +                    }
 +                    i++;
 +                } else {
 +                    b = buf[i++];
 +                    if (search_state == ONE_ZERO)
 +                        search_state = b ? NO_MATCH : TWO_ZEROS;
 +                    else if (search_state == TWO_ZEROS) {
 +                        if (b >= 1)
 +                            search_state = b == 1 ? ONE : NO_MATCH;
 +                    }
 +                    else { // search_state == ONE
 +                        search_state = NO_MATCH;
 +                        start_code_found = 1;
 +                        break;
 +                    }
 +                }
 +            }
 +        }
 +        if (start_code_found) {
 +            vc1_extract_header(s, avctx, unesc_buffer, unesc_index);
 +
 +            vpc->prev_start_code = b;
 +            unesc_index = 0;
 +
 +            if (!(s->flags & PARSER_FLAG_COMPLETE_FRAMES)) {
 +                if (!pic_found && (b == (VC1_CODE_FRAME & 0xFF) || b == (VC1_CODE_FIELD & 0xFF))) {
 +                    pic_found = 1;
 +                }
 +                else if (pic_found && b != (VC1_CODE_FIELD & 0xFF) && b != (VC1_CODE_SLICE & 0xFF)) {
 +                    next = i - 4;
 +                    pic_found = b == (VC1_CODE_FRAME & 0xFF);
 +                    break;
 +                }
 +            }
 +        }
 +    }
  
 +    vpc->pc.frame_start_found = pic_found;
 +    vpc->unesc_index = unesc_index;
 +    vpc->search_state = search_state;
 +
 +    if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
 +        next = buf_size;
 +    } else {
          if (ff_combine_frame(&vpc->pc, next, &buf, &buf_size) < 0) {
 +            vpc->bytes_to_skip = 0;
              *poutbuf = NULL;
              *poutbuf_size = 0;
              return buf_size;
Simple merge
Simple merge