Revision dc338d17 libavcodec/bethsoftvideo.c

View differences:

libavcodec/bethsoftvideo.c
51 51
{
52 52
    uint32_t * palette = (uint32_t *)frame->data[1];
53 53
    int a;
54
    for(a = 0; a < 256; a++)
55
    {
54
    for(a = 0; a < 256; a++){
56 55
        palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;    // multiply all colors by 4
57 56
    }
58 57
    frame->palette_has_changed = 1;
......
81 80
    destination = vid->frame.data[0];
82 81
    frame_end = vid->frame.data[0] + vid->frame.linesize[0] * avctx->height;
83 82

  
84
    switch(block_type = *buf++)
85
    {
86
        case PALETTE_BLOCK: set_palette(&vid->frame, buf); return 0;
83
    switch(block_type = *buf++){
84
        case PALETTE_BLOCK:
85
            set_palette(&vid->frame, buf);
86
            return 0;
87 87
        case VIDEO_YOFF_P_FRAME:
88 88
            yoffset = bytestream_get_le16(&buf);
89
            if(yoffset >= avctx->height) { return -1; }
89
            if(yoffset >= avctx->height)
90
                return -1;
90 91
            destination += vid->frame.linesize[0] * yoffset;
91 92
    }
92 93

  
93 94
    // main code
94
    while((rle_num_bytes = *buf++))
95
    {
95
    while((rle_num_bytes = *buf++)){
96 96
        int length = rle_num_bytes & 0x7f;
97 97

  
98 98
        // copy any bytes starting at the current position, and ending at the frame width
99
        while(length > line_remaining)
100
        {
101
            if(rle_num_bytes < 0x80) { bytestream_get_buffer(&buf, destination, line_remaining); }
102
            else if(block_type == VIDEO_I_FRAME) { memset(destination, buf[0], line_remaining); }
99
        while(length > line_remaining){
100
            if(rle_num_bytes < 0x80)
101
                bytestream_get_buffer(&buf, destination, line_remaining);
102
            else if(block_type == VIDEO_I_FRAME)
103
                memset(destination, buf[0], line_remaining);
103 104
            length -= line_remaining;      // decrement the number of bytes to be copied
104 105
            destination += line_remaining + wrap_to_next_line;    // skip over extra bytes at end of frame
105 106
            line_remaining = avctx->width;
106
            if(destination == frame_end) { goto end; }
107
            if(destination == frame_end)
108
                goto end;
107 109
        }
108 110

  
109 111
        // copy any remaining bytes after / if line overflows
110
        if(rle_num_bytes < 0x80) { bytestream_get_buffer(&buf, destination, length); }
111
        else if(block_type == VIDEO_I_FRAME) { memset(destination, *buf++, length); }
112
        if(rle_num_bytes < 0x80)
113
            bytestream_get_buffer(&buf, destination, length);
114
        else if(block_type == VIDEO_I_FRAME)
115
            memset(destination, *buf++, length);
112 116
        line_remaining -= length;
113 117
        destination += length;
114 118
    }
......
124 128
{
125 129
    BethsoftvidContext * vid = avctx->priv_data;
126 130
    av_log(avctx, AV_LOG_DEBUG, "[bethsoftvid video decoder] closing\n");
127
    if(vid->frame.data[0]) { avctx->release_buffer(avctx, &vid->frame); }
131
    if(vid->frame.data[0])
132
        avctx->release_buffer(avctx, &vid->frame);
128 133
    return 0;
129 134
}
130 135

  

Also available in: Unified diff