Daniel,

It's hard to help you debug this without knowing what you are feeding
in. To be clear -- you are using a valid MPEG-2 video elementary
stream that plays perfectly fine with mpeg2dec and the other sample
decoders distributed with libmpeg2? Maybe if you can post a sample of
your file, I can help you debug why your code gives STATE_INVALID
while the sample decoders don't, if that's what's happening.

Best,
Keith

On Mon, Jun 13, 2011 at 3:27 AM, Daniel Tang <dt.ta...@gmail.com> wrote:
> Hi,
>
> I've just compiled libmpeg2 for an embedded platform and have written some 
> code for decoding. But the call to mpeg2_parse in this code seems to always 
> return STATE_INVALID.
>
> int play(FILE * mpgfile)
> {
>        mpeg2dec_t * decoder;
>   const mpeg2_info_t * info;
>   mpeg2_state_t state;
>   size_t size = 1;
>        unsigned char *buffer = malloc(BUFFER_SIZE);
>
>        char debug[20];
>        if (!buffer) {
>                show_msgbox("NspireMoviePlayer","NULL ptr from Malloc");
>                return 1;
>        }
>
>        decoder = mpeg2_init ();
>   if (!decoder) {
>        show_msgbox("NspireMoviePlayer","Could not init mpeg2");
>                return 1;
>        }
>
>   info = mpeg2_info (decoder);
>        do
>        {
>                state = mpeg2_parse (decoder);
>                switch (state) {
>                        case STATE_BUFFER:
>                        size = fread (buffer, 1, BUFFER_SIZE, mpgfile);
>                        mpeg2_buffer (decoder, buffer, buffer + size);
>                        break;
>                        case STATE_SEQUENCE:
>                        mpeg2_convert (decoder, mpeg2convert_rgb24, NULL);
>                        settimerperiod(info->sequence->frame_period);
>                        break;
>                        case STATE_SLICE:
>                        case STATE_END:
>                                if (info->sequence->width  != SCREEN_WIDTH ||
>                                        info->sequence->height != 
> SCREEN_HEIGHT)
>                                {
>                                        
> show_msgbox("NspireMoviePlayer","Screen size mismatch");
>                                        goto die;
>                                }
>                                else {
>                                        waittimerperiod();
>                                        
> renderframe(info->display_fbuf->buf[0]);
>                                }
>                                break;
>                        case STATE_INVALID:
>                                goto die;
>                        break;
>                        default:
>                        break;
>                }
>        } while(size);
>
>        mpeg2_close(decoder);
>        return 0;
>
>        die:
>        mpeg2_close(decoder);
>        return 1;
> }
>
> I dug around decode.c and added some debugging messages and it seems it's 
> conking out in this piece of code at the bottom of mpeg2_parse:
>
> mpeg2dec->action = mpeg2_seek_header;
>   switch (mpeg2dec->code) {
>   case 0x00:
>   show_msgbox("libmpeg2","case 0 mpeg2dec->code");
>        return mpeg2dec->state;
>   case 0xb3:
>   case 0xb7:
>   case 0xb8:
>   show_msgbox("libmpeg2","case b8 mpeg2dec->code");
>        return (mpeg2dec->state == STATE_SLICE) ? STATE_SLICE : STATE_INVALID;
>   default:
>        mpeg2dec->action = seek_chunk;
>        show_msgbox("libmpeg2","default mpeg2dec->code"); // This is where it 
> returns
>        return STATE_INVALID;
>   }
>
> Does anyone have any ideas on what could be causing this? The code isn't very 
> well documented and it's hard to follow.
>
> Cheers,
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Libmpeg2-devel mailing list
> Libmpeg2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel
>

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Libmpeg2-devel mailing list
Libmpeg2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel

Reply via email to