<br><div class="gmail_quote">On Thu, Sep 16, 2010 at 10:33 AM, Varun Dua <span dir="ltr">&lt;<a href="mailto:varundua007@gmail.com">varundua007@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div class="gmail_quote">Hi All<div><div></div><div class="h5"><br><br>I am using the hwdecode examples, they are building and running fine. <br><br>I changed the file ffmpeg_video.c to make it decode a video. Below is the changed function that I am posting. The commented out portion is the original code. I changed that to make it work for decoding a video but it is giving a lot of artifacts.<br>



<br>Please tell me what needs to done. I am not changing the surface_id or the context_id anywhere. <br><br>***********************************************<br>***********************************************<br>int decode(void)<br>



{<br>    AVProbeData pd;<br>    ByteIOContext ioctx;<br>    AVInputFormat *format = NULL;<br>    AVFormatContext *ic = NULL;<br>    AVCodec *codec;<br>    AVCodecContext *avctx = NULL;<br>    AVPacket packet;<br>    AVStream *video_stream;<br>



    int i, got_picture, error = -1;<br><br>    const uint8_t *video_data;<br>    unsigned int video_data_size;<br><br>    av_register_all();<br>    av_init_packet(&amp;packet);<br> <br>   /*codec_get_video_data(&amp;video_data, &amp;video_data_size);<br>



    pd.filename = &quot;&quot;;<br>    pd.buf      = (uint8_t *)video_data;<br>    pd.buf_size = MIN(video_data_size, 32*1024);<br>    if (FORCE_VIDEO_FORMAT)<br>        format = av_find_input_format(FORCE_VIDEO_FORMAT);<br>



    if (format == NULL &amp;&amp; (format = av_probe_input_format(&amp;pd, 1)) == NULL)<br>        goto end;<br>    format-&gt;flags |= AVFMT_NOFILE;<br><br>    if (init_put_byte(&amp;ioctx, (uint8_t *)video_data, video_data_size, 0, NULL, NULL, NULL, NULL) &lt; 0)<br>



        goto end;<br><br>    if (av_open_input_stream(&amp;ic, &amp;ioctx, &quot;&quot;, format, NULL) &lt; 0)<br>        goto end;<br>*/<br>    av_open_input_file(&amp;ic,&quot;movies/high.mp4&quot;,NULL,0,NULL);<br>    if (av_find_stream_info(ic) &lt; 0)<br>



        goto end;<br>    dump_format(ic, 0, &quot;&quot;, 0);<br><br>    video_stream = NULL;<br>    for (i = 0; i &lt; ic-&gt;nb_streams; i++) {<br>        if (ic-&gt;streams[i]-&gt;codec-&gt;codec_type == CODEC_TYPE_VIDEO &amp;&amp; !video_stream)<br>



            video_stream = ic-&gt;streams[i];<br>        else<br>            ic-&gt;streams[i]-&gt;discard = AVDISCARD_ALL;<br>    }<br>    if (video_stream == NULL)<br>        goto end;<br>    avctx = video_stream-&gt;codec;<br>



    if (ffmpeg_init_context(avctx) &lt; 0)<br>        goto end;<br><br>    if ((codec = avcodec_find_decoder(avctx-&gt;codec_id)) == NULL)<br>        goto end;<br>    if (avcodec_open(avctx, codec) &lt; 0)<br>        goto end;<br>



<br>    got_picture = 0;<br>    while (av_read_frame(ic, &amp;packet) == 0) {<br>        if (packet.stream_index != video_stream-&gt;index)<br>            continue;<br>        if ((got_picture = ffmpeg_decode(avctx, packet.data, packet.size)) &lt; 0)<br>



            goto end;<br>        /* read only one frame */<br>        if (got_picture) {<br>            error = 0;<br>        display();<br>            //break;<br>        }<br>    //av_free_packet()<br>    }<br>    /*if (!got_picture) {<br>



        if ((got_picture = ffmpeg_decode(avctx, NULL, 0)) &lt; 0)<br>            goto end;<br>        error = 0;<br>    }*/<br><br>end:<br>    av_free_packet(&amp;packet);<br>    if (avctx)<br>        avcodec_close(avctx);<br>



    if (ic)<br>        av_close_input_stream(ic);<br>    return error;<br>}<br>************************************************<br>************************************************<br><br>Thanks for your help<br clear="all">



Regards<br><font color="#888888">Varun Dua<br>Integ. M.Tech in Mathematics and Computing<br>Mathematics Department<br>IIT Delhi<br><br>
</font></div></div></div><br>
</blockquote></div><br>Hi All<br>
<br>
I figure that the problem is when there is motion in the frame. For 
static images the code works fine, but when I do the same for a video it gives
 me artifacts at the frames which have some motion in them. Please tell 
me where I might be wrong. <br>
<br>
Thanks<br>
Varun Dua<br>