[Libva] Problem with HWDecode examples
Varun Dua
varundua007 at gmail.com
Wed Sep 15 22:03:05 PDT 2010
Hi All
I am using the hwdecode examples, they are building and running fine.
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.
Please tell me what needs to done. I am not changing the surface_id or the
context_id anywhere.
***********************************************
***********************************************
int decode(void)
{
AVProbeData pd;
ByteIOContext ioctx;
AVInputFormat *format = NULL;
AVFormatContext *ic = NULL;
AVCodec *codec;
AVCodecContext *avctx = NULL;
AVPacket packet;
AVStream *video_stream;
int i, got_picture, error = -1;
const uint8_t *video_data;
unsigned int video_data_size;
av_register_all();
av_init_packet(&packet);
/*codec_get_video_data(&video_data, &video_data_size);
pd.filename = "";
pd.buf = (uint8_t *)video_data;
pd.buf_size = MIN(video_data_size, 32*1024);
if (FORCE_VIDEO_FORMAT)
format = av_find_input_format(FORCE_VIDEO_FORMAT);
if (format == NULL && (format = av_probe_input_format(&pd, 1)) == NULL)
goto end;
format->flags |= AVFMT_NOFILE;
if (init_put_byte(&ioctx, (uint8_t *)video_data, video_data_size, 0,
NULL, NULL, NULL, NULL) < 0)
goto end;
if (av_open_input_stream(&ic, &ioctx, "", format, NULL) < 0)
goto end;
*/
av_open_input_file(&ic,"movies/high.mp4",NULL,0,NULL);
if (av_find_stream_info(ic) < 0)
goto end;
dump_format(ic, 0, "", 0);
video_stream = NULL;
for (i = 0; i < ic->nb_streams; i++) {
if (ic->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO &&
!video_stream)
video_stream = ic->streams[i];
else
ic->streams[i]->discard = AVDISCARD_ALL;
}
if (video_stream == NULL)
goto end;
avctx = video_stream->codec;
if (ffmpeg_init_context(avctx) < 0)
goto end;
if ((codec = avcodec_find_decoder(avctx->codec_id)) == NULL)
goto end;
if (avcodec_open(avctx, codec) < 0)
goto end;
got_picture = 0;
while (av_read_frame(ic, &packet) == 0) {
if (packet.stream_index != video_stream->index)
continue;
if ((got_picture = ffmpeg_decode(avctx, packet.data, packet.size)) <
0)
goto end;
/* read only one frame */
if (got_picture) {
error = 0;
display();
//break;
}
//av_free_packet()
}
/*if (!got_picture) {
if ((got_picture = ffmpeg_decode(avctx, NULL, 0)) < 0)
goto end;
error = 0;
}*/
end:
av_free_packet(&packet);
if (avctx)
avcodec_close(avctx);
if (ic)
av_close_input_stream(ic);
return error;
}
************************************************
************************************************
Thanks for your help
Regards
Varun Dua
Integ. M.Tech in Mathematics and Computing
Mathematics Department
IIT Delhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libva/attachments/20100916/bd42fb36/attachment.htm>
More information about the Libva
mailing list