<div class="gmail_quote">Hi All<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(&packet);<br> <br> /*codec_get_video_data(&video_data, &video_data_size);<br>
pd.filename = "";<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 && (format = av_probe_input_format(&pd, 1)) == NULL)<br> goto end;<br> format->flags |= AVFMT_NOFILE;<br><br> if (init_put_byte(&ioctx, (uint8_t *)video_data, video_data_size, 0, NULL, NULL, NULL, NULL) < 0)<br>
goto end;<br><br> if (av_open_input_stream(&ic, &ioctx, "", format, NULL) < 0)<br> goto end;<br>*/<br> av_open_input_file(&ic,"movies/high.mp4",NULL,0,NULL);<br> if (av_find_stream_info(ic) < 0)<br>
goto end;<br> dump_format(ic, 0, "", 0);<br><br> video_stream = NULL;<br> for (i = 0; i < ic->nb_streams; i++) {<br> if (ic->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO && !video_stream)<br>
video_stream = ic->streams[i];<br> else<br> ic->streams[i]->discard = AVDISCARD_ALL;<br> }<br> if (video_stream == NULL)<br> goto end;<br> avctx = video_stream->codec;<br>
if (ffmpeg_init_context(avctx) < 0)<br> goto end;<br><br> if ((codec = avcodec_find_decoder(avctx->codec_id)) == NULL)<br> goto end;<br> if (avcodec_open(avctx, codec) < 0)<br> goto end;<br>
<br> got_picture = 0;<br> while (av_read_frame(ic, &packet) == 0) {<br> if (packet.stream_index != video_stream->index)<br> continue;<br> if ((got_picture = ffmpeg_decode(avctx, packet.data, packet.size)) < 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)) < 0)<br> goto end;<br> error = 0;<br> }*/<br><br>end:<br> av_free_packet(&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><br>