Revision e7316976 libavcodec/h261.c

View differences:

libavcodec/h261.c
851 851
    vop_found= pc->frame_start_found;
852 852
    state= pc->state;
853 853
   
854
    i=0;
855
    if(!vop_found){
856
        for(i=0; i<buf_size; i++){
857
            state= (state<<8) | buf[i];
858
            for(j=0; j<8; j++){
859
                if(( (  (state<<j)  |  (buf[i]>>(8-j))  )>>(32-20) == 0x10 )&&(((state >> (17-j)) & 0x4000) == 0x0)){
860
                    i++;
861
                    vop_found=1;
862
                    break;
863
                }
854
    for(i=0; i<buf_size && !vop_found; i++){
855
        state= (state<<8) | buf[i];
856
        for(j=0; j<8; j++){
857
            if(((state>>j)&0xFFFFF) == 0x00010){
858
                i++;
859
                vop_found=1;
860
                break;
864 861
            }
865
            if(vop_found)
866
                    break;    
867 862
        }
868 863
    }
869 864
    if(vop_found){
870 865
        for(; i<buf_size; i++){
871
            if(avctx->flags & CODEC_FLAG_TRUNCATED)//XXX ffplay workaround, someone a better solution?
872
                state= (state<<8) | buf[i];
866
            state= (state<<8) | buf[i];
873 867
            for(j=0; j<8; j++){
874
                if(( (  (state<<j)  |  (buf[i]>>(8-j))  )>>(32-20) == 0x10 )&&(((state >> (17-j)) & 0x4000) == 0x0)){
868
                if(((state>>j)&0xFFFFF) == 0x00010){
875 869
                    pc->frame_start_found=0;
876
                    pc->state=-1;
877
                    return i-3;
870
                    pc->state= state>>(2*8);
871
                    return i-1;
878 872
                }
879 873
            }
880 874
        }
......
908 902
 * returns the number of bytes consumed for building the current frame
909 903
 */
910 904
static int get_consumed_bytes(MpegEncContext *s, int buf_size){
911
    if(s->flags&CODEC_FLAG_TRUNCATED){
912
        int pos= (get_bits_count(&s->gb)+7)>>3;
913
        pos -= s->parse_context.last_index;
914
        if(pos<0) pos=0;// padding is not really read so this might be -1
915
        return pos;
916
    }else{
917
        int pos= get_bits_count(&s->gb)>>3;
918
        if(pos==0) pos=1; //avoid infinite loops (i doubt thats needed but ...)
919
        if(pos+10>buf_size) pos=buf_size; // oops ;)
905
    int pos= get_bits_count(&s->gb)>>3;
906
    if(pos==0) pos=1; //avoid infinite loops (i doubt thats needed but ...)
907
    if(pos+10>buf_size) pos=buf_size; // oops ;)
920 908

  
921
        return pos;
922
    }
909
    return pos;
923 910
}
924 911

  
925 912
static int h261_decode_frame(AVCodecContext *avctx,
......
942 929
    if (buf_size == 0) {
943 930
        return 0;
944 931
    }
945

  
946
    if(s->flags&CODEC_FLAG_TRUNCATED){
947
        int next;
948

  
949
        next= h261_find_frame_end(&s->parse_context,avctx, buf, buf_size);
950

  
951
        if( ff_combine_frame(&s->parse_context, next, &buf, &buf_size) < 0 )
952
            return buf_size;
953
    }
954

  
932
    
933
    h->gob_start_code_skipped=0;
955 934

  
956 935
retry:
957 936

  
......
1013 992

  
1014 993
assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
1015 994
assert(s->current_picture.pict_type == s->pict_type);
1016
    *pict= *(AVFrame*)&s->current_picture;
995
    *pict= *(AVFrame*)s->current_picture_ptr;
1017 996
    ff_print_debug_info(s, pict);
1018 997

  
1019 998
    /* Return the Picture timestamp as the frame number */
......
1053 1032
    NULL,
1054 1033
    h261_decode_end,
1055 1034
    h261_decode_frame,
1056
    CODEC_CAP_TRUNCATED,
1035
    CODEC_CAP_DR1,
1057 1036
};
1058 1037

  
1059 1038
AVCodecParser h261_parser = {

Also available in: Unified diff