[Libav-user] Decoding Problem (got_picture always return 0)
ZHAO Yinxia
hydezhao at gmail.com
Fri Mar 23 17:37:49 CET 2012
Thank you Hung, Nguyen Viet ,
I've added these 32 bits headers, but it does not work. my program at
server end is something like this:
int saveFrame(void *ctx, unsigned char *pixels, int frameWidth, int
frameHeight, unsigned char **out, int *len)
{
Ctx *c = (Ctx*)ctx;
// convert RGB colorspace image buffer to YCrCb format
RGB2YUV(frameWidth, frameHeight, pixels, pic_in.img.plane[0],
pic_in.img.plane[1], pic_in.img.plane[2], false);
for (int i =0; i<4; i++)
{
c->picture.img.plane[i] = pic_in.img.plane[i];
c->picture.img.i_stride[i] = frameWidth;
}
// c->picture.i_pts=c->get_pts(c);
x264_picture_t pic_out;
x264_nal_t* nals;
x264_picture_t *pic = &c->picture;
int i_nals;
int frame_size = x264_encoder_encode(c->x264, &nals, &i_nals, pic,
&pic_out);
if( frame_size )
encode_nals(c, nals, i_nals);
*out = (unsigned char *)c->output;
*len = c->output_datasize;
if (i_nals > 0) {
c->info_valid = 1;
c->info_key_frame = pic_out.b_keyframe;
c->info_pts = pic_out.i_pts;
c->info_dts = pic_out.i_dts;
}
else return 0;
return 1;
}
static int encode_nals (Ctx *c, x264_nal_t *nals, int nal_cnt)
{
char *pout = (char*)c->output;
c->output_datasize = 0;
for (int i = 0; i < nal_cnt; i++) {
if (c->output_datasize + nals[i].i_payload > c->output_bufsize) {
c->output_bufsize =
(c->output_datasize+nals[i].i_payload+frameWidth)/frameWidth * frameHeight;
c->output = realloc(c->output, c->output_bufsize);
}
memcpy(pout+c->output_datasize, nals[i].p_payload, nals[i].i_payload);
c->output_datasize += nals[i].i_payload;
}
return c->output_datasize;
}
Sincerely,
Yinxia
2012/3/23 Việt Hùng Nguyễn <hungtrodt5 at gmail.com>
> And before you send data to decoder, remember put 4 bytes header 0x00 0x00
> 0x00 0x01.
>
> Hung, Nguyen Viet
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120323/7c454624/attachment.html>
More information about the Libav-user
mailing list