[FFmpeg-devel] Fwd: [PATCH] Psygnosis YOP demuxer

Michael Niedermayer michaelni
Thu Mar 18 00:31:59 CET 2010


On Wed, Mar 17, 2010 at 12:52:42PM +0530, Mohamed Naufal wrote:
> On 16 March 2010 06:25, Michael Niedermayer <michaelni at gmx.at> wrote:
> 
> [...]
> 
> >
> > you move the increasing to the else, this breaks the code
> > you dont have to move it there to remove current_tab_byte
> >
> 
> Please find the updated patch attached.

[...]
> +/**
> + * Lookup table for copying macroblocks. Each entry contains the respective
> + * x and y pixel offset for the copy source.
> + */
> +static const int8_t motion_vector[16][2] = {{-4, -4},
> +                                            {-2, -4},
> +                                            { 0, -4},
> +                                            { 2, -4},
> +                                            {-4, -2},
> +                                            {-4,  0},
> +                                            {-3, -3},
> +                                            {-1, -3},
> +                                            { 1, -3},
> +                                            { 3, -3},
> +                                            {-3, -1},
> +                                            {-2, -2},
> +                                            { 0, -2},
> +                                            { 2, -2},
> +                                            { 4, -2},
> +                                            {-2,  0},
> +                                           };
> +
> +static av_cold int yop_decode_init(AVCodecContext *avctx)
> +{
> +    YopDecContext *s = avctx->priv_data;
> +
> +    s->avctx = avctx;
> +
> +    if (avctx->width & 1 || avctx->height & 1 ||
> +        avcodec_check_dimensions(avctx, avctx->width, avctx->height)) {
> +        av_log(avctx, AV_LOG_ERROR, "YOP has invalid dimensions\n");
> +        return -1;
> +    }
> +
> +    avctx->pix_fmt = PIX_FMT_RGB24;

doesnt the decoder work with PAL8 ?

[...]
> +static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
> +                            AVPacket *avpkt)
> +{
> +    YopDecContext *s = avctx->priv_data;
> +    uint8_t current_byte = 0;
> +
> +    if (!s->frame.data[0]) {
> +        s->frame.data[0] = av_mallocz(s->frame.linesize[0] * avctx->height);
> +        if (!s->frame.data[0])
> +            return AVERROR(ENOMEM);
> +
> +        s->frame.base[0]   = s->frame.data[0];
> +        s->frame.key_frame = 1;
> +    }
> +
> +    s->srcptr  =  avpkt->data + 4;
> +    s->dstbuf  =  s->frame.data[0];
> +    s->dstptr  =  s->frame.data[0];
> +    s->row_pos =  0;
> +
> +    // Copy the frame palette into our struct
> +    yop_update_palette(s, !(avpkt->flags & PKT_FLAG_KEY));
> +
> +    while (s->dstptr - s->dstbuf <
> +           avctx->width * RGB_COLORS * avctx->height &&
> +           s->srcptr - avpkt->data < avpkt->size) {
> +
> +        yop_get_next_nibble(s, &current_byte);
> +

> +        if ((current_byte & 0xf0) != 0xf0) {
> +            yop_paint_block(s, current_byte >> 4);
> +        }else {
> +            yop_get_next_nibble(s, &current_byte);
> +            yop_copy_previous_block(s, current_byte >> 4);
> +        }

extracting the top 4bits is done several times


[...]
> +static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +    YopDecContext *yop = s->priv_data;
> +    ByteIOContext *pb  = s->pb;
> +
> +    int ret;
> +    int palette_size           = 4 + yop->num_pal_colors * 3;
> +    int actual_video_data_size = yop->frame_size -
> +                                 yop->audio_block_length - palette_size;
> +
> +    yop->video_packet.stream_index = 1;
> +
> +    if (yop->video_packet.data) {
> +        *pkt                   =  yop->video_packet;
> +        yop->video_packet.data =  NULL;
> +        yop->video_packet.size =  0;
> +
> +        if (!yop->odd_frame)
> +            pkt->flags |= PKT_FLAG_KEY;
[...]
> +static int yop_read_seek(AVFormatContext *s, int stream_index,
> +                         int64_t timestamp, int flags)
> +{
> +    YopDecContext *yop = s->priv_data;
> +    int64_t frame_pos, pos_min, pos_max;
> +
> +    av_free_packet(&yop->video_packet);
> +
> +    pos_min = s->data_offset;
> +    pos_max = url_fsize(s->pb) - yop->frame_size;
> +
> +    if(!stream_index)
> +        return -1;
> +
> +    frame_pos      = timestamp * yop->frame_size + pos_min;
> +    yop->odd_frame = timestamp & 1;

this code is a bit inconsistent.
are half of the frames really more keyframe than the other
half? if not you cannot set keyframe for one half different than the
other.
if they are you cannot seek to one half

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100318/5f75bd4d/attachment.pgp>



More information about the ffmpeg-devel mailing list