Ticket #676: hack.diff

File hack.diff, 3.1 KB (added by Elon Musk, 15 years ago)
  • libavcodec/avcodec.h

    diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
    index dfd396c..816102b 100644
    a b typedef struct AVPanScan{  
    840840
    841841enum AVPacketSideDataType {
    842842    AV_PKT_DATA_PALETTE,
     843    AV_PKT_DATA_FRAME_SIZE,
    843844};
    844845
    845846typedef struct AVPacket {
  • libavcodec/interplayvideo.c

    diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
    index c8aa8bf..c91069e 100644
    a b static int ipvideo_decode_frame(AVCodecContext *avctx,  
    10391039    int buf_size = avpkt->size;
    10401040    IpvideoContext *s = avctx->priv_data;
    10411041
     1042    const unsigned int *size = (unsigned int *)av_packet_get_side_data(avpkt, AV_PKT_DATA_FRAME_SIZE, NULL);
     1043    if (size) {
     1044        av_log(NULL, AV_LOG_ERROR, "%dx%d\n", size[0], size[1]);
     1045        avcodec_set_dimensions(avctx, size[0], size[1]);
     1046        s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2);
     1047    }
    10421048    /* compressed buffer needs to be large enough to at least hold an entire
    10431049     * decoding map */
    10441050    if (buf_size < s->decoding_map_size)
  • libavformat/ipmovie.c

    diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
    index 562b19a..7b651aa 100644
    a b typedef struct IPMVEContext {  
    8888    int64_t video_pts;
    8989    uint32_t     palette[256];
    9090    int          has_palette;
     91    int          changed;
    9192
    9293    unsigned int audio_bits;
    9394    unsigned int audio_channels;
    static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,  
    162163            }
    163164        }
    164165
     166        unsigned int *frame_size;
     167        if (s->changed) {
     168            frame_size = (unsigned int *)av_packet_new_side_data(pkt, AV_PKT_DATA_FRAME_SIZE, 2 * sizeof(unsigned int));
     169            if (frame_size) {
     170                frame_size[0] = s->video_width;
     171                frame_size[1] = s->video_height;
     172            }
     173            s->changed = 0;
     174        }
    165175        pkt->pos= s->decode_map_chunk_offset;
    166176        avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET);
    167177        s->decode_map_chunk_offset = 0;
    static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,  
    217227    int first_color, last_color;
    218228    int audio_flags;
    219229    unsigned char r, g, b;
     230    unsigned int width, height;
    220231
    221232    /* see if there are any pending packets */
    222233    chunk_type = load_ipmovie_packet(s, pb, pkt);
    static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,  
    373384                chunk_type = CHUNK_BAD;
    374385                break;
    375386            }
    376             s->video_width = AV_RL16(&scratch[0]) * 8;
    377             s->video_height = AV_RL16(&scratch[2]) * 8;
     387            width = AV_RL16(&scratch[0]) * 8;
     388            height = AV_RL16(&scratch[2]) * 8;
     389            if (width != s->video_width) {
     390                s->video_width = width;
     391                s->changed++;
     392            }
     393            if (height != s->video_height) {
     394                s->video_height = height;
     395                s->changed++;
     396            }
    378397            if (opcode_version < 2 || !AV_RL16(&scratch[6])) {
    379398                s->video_bpp = 8;
    380399            } else {