Browse Source

bethsoftvid: pass palette in side data instead of in a separate packet.

Update FATE reference to account for now non-existent palette packet.
This also fixes the FATE test if frame data is not initialized in
get_buffer(), so update comment in avconv accordingly.
tags/n0.11
Justin Ruggles 14 years ago
parent
commit
f320fb894c
4 changed files with 112 additions and 80 deletions
  1. +1
    -1
      avconv.c
  2. +11
    -3
      libavcodec/bethsoftvideo.c
  3. +29
    -6
      libavformat/bethsoftvid.c
  4. +71
    -70
      tests/ref/fate/bethsoft-vid

+ 1
- 1
avconv.c View File

@@ -449,7 +449,7 @@ static int alloc_buffer(InputStream *ist, FrameBuffer **pbuf)
/* XXX this shouldn't be needed, but some tests break without this line
* those decoders are buggy and need to be fixed.
* the following tests fail:
* bethsoft-vid, cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit
* cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit
*/
memset(buf->base[0], 128, ret);



+ 11
- 3
libavcodec/bethsoftvideo.c View File

@@ -71,14 +71,23 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
uint8_t * dst;
uint8_t * frame_end;
int remaining = avctx->width; // number of bytes remaining on a line
const int wrap_to_next_line = vid->frame.linesize[0] - avctx->width;
int code;
int wrap_to_next_line;
int code, ret;
int yoffset;

if (avctx->reget_buffer(avctx, &vid->frame)) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
}
wrap_to_next_line = vid->frame.linesize[0] - avctx->width;

if (avpkt->side_data_elems > 0 &&
avpkt->side_data[0].type == AV_PKT_DATA_PALETTE) {
bytestream2_init(&vid->g, avpkt->side_data[0].data,
avpkt->side_data[0].size);
if ((ret = set_palette(vid)) < 0)
return ret;
}

bytestream2_init(&vid->g, avpkt->data, avpkt->size);
dst = vid->frame.data[0];
@@ -86,7 +95,6 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,

switch(block_type = bytestream2_get_byte(&vid->g)){
case PALETTE_BLOCK: {
int ret;
*data_size = 0;
if ((ret = set_palette(vid)) < 0) {
av_log(avctx, AV_LOG_ERROR, "error reading palette\n");


+ 29
- 6
libavformat/bethsoftvid.c View File

@@ -32,6 +32,8 @@
#include "internal.h"
#include "libavcodec/bethsoftvideo.h"

#define BVID_PALETTE_SIZE 3 * 256

typedef struct BVID_DemuxContext
{
int nframes;
@@ -43,6 +45,7 @@ typedef struct BVID_DemuxContext
/** video presentation time stamp.
* delay = 16 milliseconds * (global_delay + per_frame_delay) */
int video_pts;
uint8_t *palette;

int is_finished;

@@ -163,6 +166,14 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
pkt->stream_index = 0; // use the video decoder, which was initialized as the first stream
pkt->pts = vid->video_pts;

/* if there is a new palette available, add it to packet side data */
if (vid->palette) {
uint8_t *pdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
BVID_PALETTE_SIZE);
memcpy(pdata, vid->palette, BVID_PALETTE_SIZE);
av_freep(&vid->palette);
}

vid->nframes--; // used to check if all the frames were read
return vidbuf_nbytes;
fail:
@@ -185,14 +196,18 @@ static int vid_read_packet(AVFormatContext *s,
block_type = avio_r8(pb);
switch(block_type){
case PALETTE_BLOCK:
avio_seek(pb, -1, SEEK_CUR); // include block type
ret_value = av_get_packet(pb, pkt, 3 * 256 + 1);
if(ret_value != 3 * 256 + 1){
av_free_packet(pkt);
if (vid->palette) {
av_log(s, AV_LOG_WARNING, "discarding unused palette\n");
av_freep(&vid->palette);
}
vid->palette = av_malloc(BVID_PALETTE_SIZE);
if (!vid->palette)
return AVERROR(ENOMEM);
if (avio_read(pb, vid->palette, BVID_PALETTE_SIZE) != BVID_PALETTE_SIZE) {
av_freep(&vid->palette);
return AVERROR(EIO);
}
pkt->stream_index = 0;
return ret_value;
return vid_read_packet(s, pkt);

case FIRST_AUDIO_BLOCK:
avio_rl16(pb);
@@ -222,6 +237,13 @@ static int vid_read_packet(AVFormatContext *s,
}
}

static int vid_read_close(AVFormatContext *s)
{
BVID_DemuxContext *vid = s->priv_data;
av_freep(&vid->palette);
return 0;
}

AVInputFormat ff_bethsoftvid_demuxer = {
.name = "bethsoftvid",
.long_name = NULL_IF_CONFIG_SMALL("Bethesda Softworks VID format"),
@@ -229,4 +251,5 @@ AVInputFormat ff_bethsoftvid_demuxer = {
.read_probe = vid_probe,
.read_header = vid_read_header,
.read_packet = vid_read_packet,
.read_close = vid_read_close,
};

+ 71
- 70
tests/ref/fate/bethsoft-vid View File

@@ -1,143 +1,144 @@
#tb 0: 1/60
#tb 1: 1/11111
0, 0, 0, 1, 192000, 0x00000000
1, 0, 0, 740, 1480, 0x00000000
0, 1, 1, 1, 192000, 0x00000000
1, 740, 740, 740, 1480, 0x20a92bd4
0, 5, 5, 1, 192000, 0x01a6cf45
0, 4, 4, 1, 192000, 0x01a6cf45
1, 1480, 1480, 925, 1850, 0xa9e48a74
0, 10, 10, 1, 192000, 0xd07d57e9
0, 9, 9, 1, 192000, 0xd07d57e9
1, 2405, 2405, 740, 1480, 0x23ecd018
0, 14, 14, 1, 192000, 0x3cb1dff5
0, 13, 13, 1, 192000, 0x3cb1dff5
1, 3145, 3145, 740, 1480, 0x206bb915
0, 18, 18, 1, 192000, 0xd1aaa8fb
0, 17, 17, 1, 192000, 0xd1aaa8fb
1, 3885, 3885, 925, 1850, 0xb0e10e75
0, 23, 23, 1, 192000, 0x75f526cd
0, 22, 22, 1, 192000, 0x75f526cd
1, 4810, 4810, 740, 1480, 0x8d9baedd
0, 27, 27, 1, 192000, 0x0f673577
0, 26, 26, 1, 192000, 0x0f673577
1, 5550, 5550, 740, 1480, 0xb802aae1
0, 31, 31, 1, 192000, 0x897b6781
0, 30, 30, 1, 192000, 0x897b6781
1, 6290, 6290, 740, 1480, 0xecd7b5cc
0, 35, 35, 1, 192000, 0x81e6b7f7
0, 34, 34, 1, 192000, 0x81e6b7f7
1, 7030, 7030, 925, 1850, 0x16861355
0, 40, 40, 1, 192000, 0x1f45ce61
0, 39, 39, 1, 192000, 0x1f45ce61
1, 7955, 7955, 740, 1480, 0xa51690bd
0, 44, 44, 1, 192000, 0x5a0772a6
0, 43, 43, 1, 192000, 0x5a0772a6
1, 8695, 8695, 740, 1480, 0xdd0b90d1
0, 48, 48, 1, 192000, 0xf78732b3
0, 47, 47, 1, 192000, 0xf78732b3
1, 9435, 9435, 925, 1850, 0x3ce6e333
0, 53, 53, 1, 192000, 0x8427f9e5
0, 52, 52, 1, 192000, 0x8427f9e5
1, 10360, 10360, 740, 1480, 0xf8ce8ea3
0, 57, 57, 1, 192000, 0x40473f11
0, 56, 56, 1, 192000, 0x40473f11
1, 11100, 11100, 740, 1480, 0xda4597af
0, 61, 61, 1, 192000, 0x173ceebe
0, 60, 60, 1, 192000, 0x173ceebe
1, 11840, 11840, 740, 1480, 0x918f7cb3
0, 65, 65, 1, 192000, 0x136b9516
0, 64, 64, 1, 192000, 0x136b9516
1, 12580, 12580, 925, 1850, 0xca6edb15
0, 70, 70, 1, 192000, 0x138d11ae
0, 69, 69, 1, 192000, 0x138d11ae
1, 13505, 13505, 740, 1480, 0xba279597
0, 74, 74, 1, 192000, 0x063dbff3
0, 73, 73, 1, 192000, 0x063dbff3
1, 14245, 14245, 740, 1480, 0xc5a38a9e
0, 78, 78, 1, 192000, 0x5280852f
0, 77, 77, 1, 192000, 0x5280852f
1, 14985, 14985, 925, 1850, 0x8147eef5
0, 83, 83, 1, 192000, 0x99943a8f
0, 82, 82, 1, 192000, 0x99943a8f
1, 15910, 15910, 740, 1480, 0xce2c7cb5
0, 87, 87, 1, 192000, 0x0330a728
0, 86, 86, 1, 192000, 0x0330a728
1, 16650, 16650, 740, 1480, 0x4282819f
0, 91, 91, 1, 192000, 0x5d35467d
0, 90, 90, 1, 192000, 0x5d35467d
1, 17390, 17390, 740, 1480, 0xbdbb8da6
0, 95, 95, 1, 192000, 0xfd436343
0, 94, 94, 1, 192000, 0xfd436343
1, 18130, 18130, 925, 1850, 0xdbbeea10
0, 100, 100, 1, 192000, 0xc323fcfe
0, 99, 99, 1, 192000, 0xc323fcfe
1, 19055, 19055, 740, 1480, 0xbe6a77c2
0, 104, 104, 1, 192000, 0x2a1530a0
0, 103, 103, 1, 192000, 0x2a1530a0
1, 19795, 19795, 740, 1480, 0xa85c75b2
0, 108, 108, 1, 192000, 0xbd43bb60
0, 107, 107, 1, 192000, 0xbd43bb60
1, 20535, 20535, 925, 1850, 0xa45bde21
0, 113, 113, 1, 192000, 0xa47f5eab
0, 112, 112, 1, 192000, 0xa47f5eab
1, 21460, 21460, 740, 1480, 0x84aa7895
0, 117, 117, 1, 192000, 0xff17f5f7
0, 116, 116, 1, 192000, 0xff17f5f7
1, 22200, 22200, 740, 1480, 0x147f7d9f
0, 121, 121, 1, 192000, 0xb4140b55
0, 120, 120, 1, 192000, 0xb4140b55
1, 22940, 22940, 740, 1480, 0xc8e77b85
0, 125, 125, 1, 192000, 0xb8782cc4
0, 124, 124, 1, 192000, 0xb8782cc4
1, 23680, 23680, 925, 1850, 0x10d4d81b
0, 130, 130, 1, 192000, 0x92975b8b
0, 129, 129, 1, 192000, 0x92975b8b
1, 24605, 24605, 740, 1480, 0xb4ae8bb1
0, 134, 134, 1, 192000, 0xf42a64d6
0, 133, 133, 1, 192000, 0xf42a64d6
1, 25345, 25345, 740, 1480, 0x3ef782a5
0, 138, 138, 1, 192000, 0x2cc7077d
0, 137, 137, 1, 192000, 0x2cc7077d
1, 26085, 26085, 925, 1850, 0xdeebda14
0, 143, 143, 1, 192000, 0x00080cc8
0, 142, 142, 1, 192000, 0x00080cc8
1, 27010, 27010, 740, 1480, 0x4c7e7bbb
0, 147, 147, 1, 192000, 0x584b48f3
0, 146, 146, 1, 192000, 0x584b48f3
1, 27750, 27750, 740, 1480, 0x0e0e9198
0, 151, 151, 1, 192000, 0xd68f57da
0, 150, 150, 1, 192000, 0xd68f57da
1, 28490, 28490, 740, 1480, 0x5c1f819f
0, 155, 155, 1, 192000, 0x60158422
0, 154, 154, 1, 192000, 0x60158422
1, 29230, 29230, 925, 1850, 0x0e4cf6ff
0, 160, 160, 1, 192000, 0xd7fb89e6
0, 159, 159, 1, 192000, 0xd7fb89e6
1, 30155, 30155, 740, 1480, 0x374388a7
0, 164, 164, 1, 192000, 0x97f1c76a
0, 163, 163, 1, 192000, 0x97f1c76a
1, 30895, 30895, 740, 1480, 0xed729389
0, 168, 168, 1, 192000, 0x46c4bb9e
0, 167, 167, 1, 192000, 0x46c4bb9e
1, 31635, 31635, 925, 1850, 0xe0f1e43f
0, 173, 173, 1, 192000, 0xd32f9b66
0, 172, 172, 1, 192000, 0xd32f9b66
1, 32560, 32560, 740, 1480, 0x3b27839a
0, 177, 177, 1, 192000, 0x74f43886
0, 176, 176, 1, 192000, 0x74f43886
1, 33300, 33300, 740, 1480, 0xe6287e94
0, 181, 181, 1, 192000, 0x3c4e47df
0, 180, 180, 1, 192000, 0x3c4e47df
1, 34040, 34040, 740, 1480, 0x7e0d84b5
0, 185, 185, 1, 192000, 0xb5ac0a58
0, 184, 184, 1, 192000, 0xb5ac0a58
1, 34780, 34780, 925, 1850, 0xf08bebf7
0, 190, 190, 1, 192000, 0xcc572b31
0, 189, 189, 1, 192000, 0xcc572b31
1, 35705, 35705, 740, 1480, 0x94cf73a0
0, 194, 194, 1, 192000, 0xb1739d26
0, 193, 193, 1, 192000, 0xb1739d26
1, 36445, 36445, 740, 1480, 0xfef384ae
0, 198, 198, 1, 192000, 0x73da5473
0, 197, 197, 1, 192000, 0x73da5473
1, 37185, 37185, 925, 1850, 0x3b93e0f7
0, 203, 203, 1, 192000, 0x5f79f5bc
0, 202, 202, 1, 192000, 0x5f79f5bc
1, 38110, 38110, 740, 1480, 0x28d27bae
0, 207, 207, 1, 192000, 0x0affc0a0
0, 206, 206, 1, 192000, 0x0affc0a0
1, 38850, 38850, 740, 1480, 0x94d57da5
0, 211, 211, 1, 192000, 0x2b4d5c1c
0, 210, 210, 1, 192000, 0x2b4d5c1c
1, 39590, 39590, 740, 1480, 0xc9327db5
0, 215, 215, 1, 192000, 0x309b41bc
0, 214, 214, 1, 192000, 0x309b41bc
1, 40330, 40330, 925, 1850, 0xe781f604
0, 220, 220, 1, 192000, 0xd42b6424
0, 219, 219, 1, 192000, 0xd42b6424
1, 41255, 41255, 740, 1480, 0x752f8c5b
0, 224, 224, 1, 192000, 0x4795c948
0, 223, 223, 1, 192000, 0x4795c948
1, 41995, 41995, 740, 1480, 0x30068032
0, 228, 228, 1, 192000, 0xbc1a3a8b
0, 227, 227, 1, 192000, 0xbc1a3a8b
1, 42735, 42735, 925, 1850, 0x7895023e
0, 233, 233, 1, 192000, 0x16529c5b
0, 232, 232, 1, 192000, 0x16529c5b
1, 43660, 43660, 740, 1480, 0xa1e0a6e1
0, 237, 237, 1, 192000, 0x6b1b31ba
0, 236, 236, 1, 192000, 0x6b1b31ba
1, 44400, 44400, 740, 1480, 0x6af4b500
0, 241, 241, 1, 192000, 0x569182ce
0, 240, 240, 1, 192000, 0x569182ce
1, 45140, 45140, 740, 1480, 0xc26ea4c7
0, 245, 245, 1, 192000, 0xe6ea9866
0, 244, 244, 1, 192000, 0xe6ea9866
1, 45880, 45880, 925, 1850, 0x16a72419
0, 250, 250, 1, 192000, 0x102c6076
0, 249, 249, 1, 192000, 0x102c6076
1, 46805, 46805, 740, 1480, 0x1794aacc
0, 254, 254, 1, 192000, 0xb29f527a
0, 253, 253, 1, 192000, 0xb29f527a
1, 47545, 47545, 740, 1480, 0x2ecad8d0
0, 258, 258, 1, 192000, 0x040b4eee
0, 257, 257, 1, 192000, 0x040b4eee
1, 48285, 48285, 925, 1850, 0x2e645e07
0, 263, 263, 1, 192000, 0x92574f4a
0, 262, 262, 1, 192000, 0x92574f4a
1, 49210, 49210, 740, 1480, 0x1c54dfe7
0, 267, 267, 1, 192000, 0x1e8acdce
0, 266, 266, 1, 192000, 0x1e8acdce
1, 49950, 49950, 740, 1480, 0xbd35feec
0, 271, 271, 1, 192000, 0x1becf516
0, 270, 270, 1, 192000, 0x1becf516
1, 50690, 50690, 740, 1480, 0x419403d6
0, 275, 275, 1, 192000, 0xb62e9776
0, 274, 274, 1, 192000, 0xb62e9776
1, 51430, 51430, 925, 1850, 0x78699d2a
0, 280, 280, 1, 192000, 0xed37a08e
0, 279, 279, 1, 192000, 0xed37a08e
1, 52355, 52355, 740, 1480, 0x74ec68e0
0, 284, 284, 1, 192000, 0xc0719912
0, 283, 283, 1, 192000, 0xc0719912
1, 53095, 53095, 740, 1480, 0x76af64d9
0, 288, 288, 1, 192000, 0x24cf7a7e
0, 287, 287, 1, 192000, 0x24cf7a7e
1, 53835, 53835, 925, 1850, 0x5a303d1a
0, 293, 293, 1, 192000, 0x0307f62f
0, 292, 292, 1, 192000, 0x0307f62f
1, 54760, 54760, 537, 1074, 0x142ce7ba
0, 297, 297, 1, 192000, 0x79b7417b
0, 296, 296, 1, 192000, 0x79b7417b
1, 55297, 55297, 925, 1850, 0x7ff682f7
1, 56222, 56222, 740, 1480, 0xc33867e6

Loading…
Cancel
Save