video/avcodec: do not use uninitialized AVFrame on stack

But use avcodec_alloc_frame()/avcodec_free_frame()
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699722 for reference.
parent e388d6cc
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2010 Belledonne Communications SARL
Copyright (C) 2010 Belledonne Communications SARL
Author: Simon Morlat <simon.morlat@linphone.org>
This program is free software; you can redistribute it and/or
......@@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef struct _DecData{
mblk_t *yuv_msg;
mblk_t *sps,*pps;
AVFrame* orig;
Rfc3984Context unpacker;
MSPicture outbuf;
struct SwsContext *sws_ctx;
......@@ -78,6 +79,10 @@ static void dec_init(MSFilter *f){
d->outbuf.h=0;
d->bitstream_size=65536;
d->bitstream=ms_malloc0(d->bitstream_size);
d->orig = avcodec_alloc_frame();
if (!d->orig) {
ms_error("Could not allocate frame");
}
f->data=d;
}
......@@ -98,6 +103,7 @@ static void dec_uninit(MSFilter *f){
if (d->yuv_msg) freemsg(d->yuv_msg);
if (d->sps) freemsg(d->sps);
if (d->pps) freemsg(d->pps);
if (d->orig) avcodec_free_frame(&d->orig);
ms_free(d->bitstream);
ms_free(d);
}
......@@ -120,7 +126,7 @@ static mblk_t *get_as_yuvmsg(MSFilter *f, DecData *s, AVFrame *orig){
ctx->width,ctx->height,PIX_FMT_YUV420P,SWS_FAST_BILINEAR,
NULL, NULL, NULL);
}
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)
if (sws_scale(s->sws_ctx,(const uint8_t * const *)orig->data,orig->linesize, 0,
ctx->height, s->outbuf.planes, s->outbuf.strides)<0){
#else
......@@ -215,7 +221,7 @@ static int nalusToFrame(DecData *d, MSQueue *naluq, bool_t *new_sps_pps){
*dst++=0;
start_picture=FALSE;
}
/*prepend nal marker*/
*dst++=0;
*dst++=0;
......@@ -243,7 +249,7 @@ static void dec_process(MSFilter *f){
DecData *d=(DecData*)f->data;
mblk_t *im;
MSQueue nalus;
ms_queue_init(&nalus);
while((im=ms_queue_get(f->inputs[0]))!=NULL){
/*push the sps/pps given in sprop-parameter-sets if any*/
......@@ -270,21 +276,18 @@ static void dec_process(MSFilter *f){
int len;
int got_picture=0;
AVPacket pkt;
AVFrame orig;
/*it is required to memset the structure, because avcodec_get_frame_defaults() eventually frees non-null content*/
memset(&orig,0,sizeof(orig));
avcodec_get_frame_defaults(&orig);
avcodec_get_frame_defaults(d->orig);
av_init_packet(&pkt);
pkt.data = p;
pkt.size = end-p;
len=avcodec_decode_video2(&d->av_context,&orig,&got_picture,&pkt);
len=avcodec_decode_video2(&d->av_context,d->orig,&got_picture,&pkt);
if (len<=0) {
ms_warning("ms_AVdecoder_process: error %i.",len);
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_DECODING_ERRORS);
break;
}
if (got_picture) {
ms_queue_put(f->outputs[0],get_as_yuvmsg(f,d,&orig));
ms_queue_put(f->outputs[0],get_as_yuvmsg(f,d,d->orig));
if (!d->first_image_decoded) {
d->first_image_decoded = TRUE;
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
......
......@@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef struct {
FILE *file;
AVCodec *codec;
AVFrame* pict;
}JpegWriter;
static void jpg_init(MSFilter *f){
......@@ -40,6 +41,7 @@ static void jpg_init(MSFilter *f){
if (s->codec==NULL){
ms_error("Could not find CODEC_ID_MJPEG !");
}
s->pict = avcodec_alloc_frame();
f->data=s;
}
......@@ -48,6 +50,7 @@ static void jpg_uninit(MSFilter *f){
if (s->file!=NULL){
fclose(s->file);
}
if (s->pict) avcodec_free_frame(&s->pict);
ms_free(s);
}
......@@ -86,14 +89,13 @@ static void jpg_process(MSFilter *f){
int error,got_pict;
int comp_buf_sz=msgdsize(m);
uint8_t *comp_buf=(uint8_t*)alloca(comp_buf_sz);
AVFrame pict;
mblk_t *jpegm;
struct SwsContext *sws_ctx;
struct AVPacket packet;
AVCodecContext *avctx=avcodec_alloc_context3(s->codec);
memset(&packet, 0, sizeof(packet));
avctx->width=yuvbuf.w;
avctx->height=yuvbuf.h;
avctx->time_base.num = 1;
......@@ -115,7 +117,7 @@ static void jpg_process(MSFilter *f){
goto end;
}
jpegm=ms_yuv_buf_alloc (&yuvjpeg,avctx->width, avctx->height);
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)
if (sws_scale(sws_ctx,(const uint8_t *const*)yuvbuf.planes,yuvbuf.strides,0,avctx->height,yuvjpeg.planes,yuvjpeg.strides)<0){
#else
if (sws_scale(sws_ctx,(uint8_t **)yuvbuf.planes,yuvbuf.strides,0,avctx->height,yuvjpeg.planes,yuvjpeg.strides)<0){
......@@ -127,11 +129,11 @@ static void jpg_process(MSFilter *f){
goto end;
}
sws_freeContext(sws_ctx);
avcodec_get_frame_defaults(&pict);
avpicture_fill((AVPicture*)&pict,(uint8_t*)jpegm->b_rptr,avctx->pix_fmt,avctx->width,avctx->height);
avcodec_get_frame_defaults(s->pict);
avpicture_fill((AVPicture*)s->pict,(uint8_t*)jpegm->b_rptr,avctx->pix_fmt,avctx->width,avctx->height);
packet.data=comp_buf; packet.size=comp_buf_sz;
error=avcodec_encode_video2(avctx, &packet, &pict, &got_pict);
error=avcodec_encode_video2(avctx, &packet, s->pict, &got_pict);
if (error<0){
ms_error("Could not encode jpeg picture.");
}else{
......
......@@ -56,12 +56,12 @@ static mblk_t *jpeg2yuv(uint8_t *jpgbuf, int bufsize, MSVideoSize *reqsize){
#ifndef NO_FFMPEG
AVCodecContext av_context;
int got_picture=0;
AVFrame orig;
mblk_t *ret;
struct SwsContext *sws_ctx;
AVPacket pkt;
MSPicture dest;
AVCodec *codec=avcodec_find_decoder(CODEC_ID_MJPEG);
AVFrame* orig = avcodec_alloc_frame();
if (codec==NULL){
ms_error("Could not find MJPEG decoder in ffmpeg.");
......@@ -77,8 +77,7 @@ static mblk_t *jpeg2yuv(uint8_t *jpgbuf, int bufsize, MSVideoSize *reqsize){
pkt.data=jpgbuf;
pkt.size=bufsize;
memset(&orig, 0, sizeof(orig));
if (avcodec_decode_video2(&av_context,&orig,&got_picture,&pkt) < 0) {
if (avcodec_decode_video2(&av_context,orig,&got_picture,&pkt) < 0) {
ms_error("jpeg2yuv: avcodec_decode_video failed");
avcodec_close(&av_context);
return NULL;
......@@ -96,10 +95,10 @@ static mblk_t *jpeg2yuv(uint8_t *jpgbuf, int bufsize, MSVideoSize *reqsize){
return NULL;
}
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)
if (sws_scale(sws_ctx,(const uint8_t* const *)orig.data,orig.linesize,0,av_context.height,dest.planes,dest.strides)<0){
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)
if (sws_scale(sws_ctx,(const uint8_t* const *)orig->data,orig->linesize,0,av_context.height,dest.planes,dest.strides)<0){
#else
if (sws_scale(sws_ctx,(uint8_t**)orig.data,orig.linesize,0,av_context.height,dest.planes,dest.strides)<0){
if (sws_scale(sws_ctx,(uint8_t**)orig->data,orig->linesize,0,av_context.height,dest.planes,dest.strides)<0){
#endif
ms_error("jpeg2yuv: ms_sws_scale() failed.");
sws_freeContext(sws_ctx);
......@@ -108,13 +107,14 @@ static mblk_t *jpeg2yuv(uint8_t *jpgbuf, int bufsize, MSVideoSize *reqsize){
return NULL;
}
sws_freeContext(sws_ctx);
avcodec_free_frame(&orig);
avcodec_close(&av_context);
return ret;
#elif TARGET_OS_IPHONE
MSPicture dest;
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, jpgbuf, bufsize, NULL);
// use the data provider to get a CGImage; release the data provider
CGImageRef image = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, FALSE,
CGImageRef image = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, FALSE,
kCGRenderingIntentDefault);
CGDataProviderRelease(dataProvider);
reqsize->width = CGImageGetWidth(image);
......@@ -138,7 +138,7 @@ static mblk_t *jpeg2yuv(uint8_t *jpgbuf, int bufsize, MSVideoSize *reqsize){
uint8_t b = tmp[y * reqsize->width * 4 + x * 4 + 2];
// Y
*dest.planes[0]++ = (uint8_t)((0.257 * r) + (0.504 * g) + (0.098 * b) + 16);
*dest.planes[0]++ = (uint8_t)((0.257 * r) + (0.504 * g) + (0.098 * b) + 16);
// U/V subsampling
if ((y % 2==0) && (x%2==0)) {
......@@ -177,7 +177,7 @@ mblk_t *ms_load_jpeg_as_yuv(const char *jpgpath, MSVideoSize *reqsize){
uint8_t *jpgbuf;
DWORD err;
HANDLE fd;
#ifdef UNICODE
WCHAR wUnicode[1024];
MultiByteToWideChar(CP_UTF8, 0, jpgpath, -1, wUnicode, 1024);
......@@ -208,8 +208,8 @@ mblk_t *ms_load_jpeg_as_yuv(const char *jpgpath, MSVideoSize *reqsize){
return NULL;
}
err=0;
ReadFile(fd, jpgbuf, st_sizel, &err, NULL) ;
ReadFile(fd, jpgbuf, st_sizel, &err, NULL) ;
if (err!=st_sizel){
ms_error("Could not read as much as wanted !");
}
......@@ -395,12 +395,12 @@ static int static_image_set_image(MSFilter *f, void *arg){
SIData *d=(SIData*)f->data;
const char *image = (const char *)arg;
ms_filter_lock(f);
if (d->nowebcamimage) {
ms_free(d->nowebcamimage);
d->nowebcamimage=NULL;
}
if (image!=NULL && image[0]!='\0')
d->nowebcamimage=ms_strdup(image);
......@@ -449,7 +449,7 @@ static void static_image_detect(MSWebCamManager *obj);
static void static_image_cam_init(MSWebCam *cam){
cam->name=ms_strdup("Static picture");
if (def_image==NULL)
def_image=ms_strdup(def_image_path);
}
......
......@@ -45,13 +45,14 @@ typedef struct DecState{
int dci_size;
bool_t snow_initialized;
bool_t first_image_decoded;
AVFrame* orig;
}DecState;
static void dec_init(MSFilter *f, enum CodecID cid){
DecState *s=(DecState *)ms_new0(DecState,1);
ms_ffmpeg_check_init();
avcodec_get_context_defaults3(&s->av_context, NULL);
s->av_codec=NULL;
s->codec=cid;
......@@ -68,6 +69,10 @@ static void dec_init(MSFilter *f, enum CodecID cid){
if (s->av_codec==NULL){
ms_error("Could not find decoder %i!",s->codec);
}
s->orig = avcodec_alloc_frame();
if (!s->orig) {
ms_error("Could not allocate frame");
}
/*
s->av_context.width=MS_VIDEO_SIZE_QCIF_W;
......@@ -93,6 +98,10 @@ static void dec_snow_init(MSFilter *f){
static void dec_uninit(MSFilter *f){
DecState *s=(DecState*)f->data;
if (s->orig) {
avcodec_free_frame(&s->orig);
s->orig = NULL;
}
if (s->av_context.codec!=NULL){
avcodec_close(&s->av_context);
s->av_context.codec=NULL;
......@@ -129,7 +138,7 @@ static int dec_add_fmtp(MSFilter *f, void *data){
static void dec_preprocess(MSFilter *f){
DecState *s=(DecState*)f->data;
int error;
s->first_image_decoded = FALSE;
if (s->av_context.codec==NULL){
/* we must know picture size before initializing snow decoder*/
......@@ -149,7 +158,7 @@ static void dec_postprocess(MSFilter *f){
static mblk_t * skip_rfc2190_header(mblk_t *inm){
uint8_t *ph = inm->b_rptr;
uint8_t sbit = (ph[0] >> 3) & 0x07;
uint8_t sbit = (ph[0] >> 3) & 0x07;
//unsigned int ebit = ph[0] & 0x7;
bool_t isIFrame=0;
unsigned hdrLen;
......@@ -177,7 +186,7 @@ static mblk_t * skip_rfc2190_header(mblk_t *inm){
inm->b_rptr += hdrLen;
} else {
ms_warning("RFC2190 packet mode:%c%s too small (size %d)", mode, isIFrame ?
" (I-Frame)":"", (int)msgdsize(inm));
" (I-Frame)":"", (int)msgdsize(inm));
freemsg(inm);
inm=NULL;
}
......@@ -191,7 +200,7 @@ static mblk_t * skip_rfc2429_header(mblk_t *inm){
int PLEN;
/*int gob_num;*/
bool_t P;
P=rfc2429_get_P(ph);
PLEN=rfc2429_get_PLEN(ph);
/*printf("receiving new packet; P=%i; V=%i; PLEN=%i; PEBIT=%i\n",P,rfc2429_get_V(ph),PLEN,rfc2429_get_PEBIT(ph));
......@@ -199,7 +208,7 @@ static mblk_t * skip_rfc2429_header(mblk_t *inm){
/*gob_num = (ntohl(*p) >> 10) & 0x1f;*/
/*ms_message("gob %i, size %i", gob_num, msgdsize(inm));
ms_message("ms_AVdecoder_process: received %08x %08x", ntohl(p[0]), ntohl(p[1]));*/
/* remove H.263 Payload Header */
if (PLEN>0){
/* we ignore the redundant picture header and
......@@ -553,7 +562,7 @@ read_rfc2435_header(DecState *s,mblk_t *inm)
dri = ntohs(rsthdr->dri);
inm->b_rptr += sizeof(struct jpeghdr_rst);
}
if (off==0){
if (hdr->q>=128){
inm->b_rptr++; /* MBZ */
......@@ -573,7 +582,7 @@ read_rfc2435_header(DecState *s,mblk_t *inm)
headers = allocb(495 + table_len + (dri > 0 ? 6 : 0), 0);
len = MakeHeaders(headers->b_rptr, hdr->type, hdr->width, hdr->height,
lqt_cqt, lqt_cqt+64, table_len, dri);
headers->b_wptr += len;
headers->b_wptr += len;
}
}
......@@ -620,7 +629,7 @@ static mblk_t *get_as_yuvmsg(MSFilter *f, DecState *s, AVFrame *orig){
ms_error("%s: missing rescaling context.",f->desc->name);
return NULL;
}
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)
#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)
if (sws_scale(s->sws_ctx,(const uint8_t* const*)orig->data,orig->linesize, 0,
ctx->height, s->outbuf.planes, s->outbuf.strides)<0){
#else
......@@ -636,10 +645,10 @@ static unsigned char smasks[7] = { 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
static void dec_process_frame(MSFilter *f, mblk_t *inm){
DecState *s=(DecState*)f->data;
AVFrame orig;
int got_picture;
/* get a picture from the input queue */
if (f->desc->id==MS_H263_DEC_ID) inm=skip_rfc2429_header(inm);
else if (f->desc->id==MS_H263_OLD_DEC_ID) inm=skip_rfc2190_header(inm);
else if (s->codec==CODEC_ID_SNOW && s->input==NULL) inm=parse_snow_header(s,inm);
......@@ -649,9 +658,9 @@ static void dec_process_frame(MSFilter *f, mblk_t *inm){
/* accumulate the video packet until we have the rtp markbit*/
if (s->input==NULL){
s->input=inm;
}else{
}else{
uint8_t sbit = (inm->reserved2 >> 11) & 0x7;
if (sbit!=0) {
if (sbit!=0) {
mblk_t *mp = s->input;
while ( mp->b_cont != NULL ) mp = mp->b_cont;
mp->b_wptr--;
......@@ -661,12 +670,12 @@ static void dec_process_frame(MSFilter *f, mblk_t *inm){
}
concatb(s->input,inm);
}
if (mblk_get_marker_info(inm)){
mblk_t *frame;
int remain,len;
/*ms_message("got marker bit !");*/
/*append some padding bytes for ffmpeg to safely
/*append some padding bytes for ffmpeg to safely
read extra bytes...*/
msgpullup(s->input,msgdsize(s->input)+8);
frame=s->input;
......@@ -676,14 +685,14 @@ static void dec_process_frame(MSFilter *f, mblk_t *inm){
av_init_packet(&pkt);
pkt.data = frame->b_rptr;
pkt.size = remain;
len=avcodec_decode_video2(&s->av_context,&orig,&got_picture,&pkt);
len=avcodec_decode_video2(&s->av_context, s->orig, &got_picture,&pkt);
if (len<=0) {
ms_warning("ms_AVdecoder_process: error %i.",len);
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_DECODING_ERRORS);
break;
}
if (got_picture) {
mblk_t *om = get_as_yuvmsg(f,s,&orig);
mblk_t *om = get_as_yuvmsg(f,s,s->orig);
if (om!=NULL)
ms_queue_put(f->outputs[0],om);
......
......@@ -129,6 +129,7 @@ void ms_ffmpeg_check_init(){
typedef struct EncState{
AVCodecContext av_context;
AVCodec *av_codec;
AVFrame* pict;
enum CodecID codec;
mblk_t *comp_buf;
int mtu; /* network maximum transmission unit in bytes */
......@@ -230,6 +231,7 @@ static void enc_init(MSFilter *f, enum CodecID codec)
s->av_context.codec=NULL;
s->vconf_list = get_vconf_list(s);
s->vconf = ms_video_find_best_configuration_for_bitrate(s->vconf_list, 500000);
s->pict = avcodec_alloc_frame();
}
static void enc_h263_init(MSFilter *f){
......@@ -268,7 +270,7 @@ static void prepare(EncState *s){
/* put codec parameters */
/* in order to take in account RTP protocol overhead and avoid possible
bitrate peaks especially on low bandwidth, we make a correction on the
bitrate peaks especially on low bandwidth, we make a correction on the
codec's target bitrate.
*/
c->bit_rate=(float)s->vconf.required_bitrate*0.92;
......@@ -300,7 +302,7 @@ static void prepare(EncState *s){
if (s->codec==CODEC_ID_SNOW){
c->strict_std_compliance=-2;
}
ms_message("Codec size set to w=%i/h=%i",c->width, c->height);
}
......@@ -334,6 +336,7 @@ static void prepare_mpeg4(EncState *s){
static void enc_uninit(MSFilter *f){
EncState *s=(EncState*)f->data;
if (s->pict) avcodec_free_frame(&s->pict);
ms_free(s);
}
......@@ -438,7 +441,7 @@ static int get_gbsc_bytealigned(uint8_t *begin, uint8_t *end){
static void rfc2190_generate_packets(MSFilter *f, EncState *s, mblk_t *frame, uint32_t timestamp){
mblk_t *packet=NULL;
while (frame->b_rptr<frame->b_wptr){
packet=dupb(frame);
/*frame->b_rptr=packet->b_wptr=packet->b_rptr+get_gbsc(packet->b_rptr, MIN(packet->b_rptr+s->mtu,frame->b_wptr));*/
......@@ -472,15 +475,15 @@ static void mpeg4_fragment_and_send(MSFilter *f,EncState *s,mblk_t *frame, uint3
static void rfc4629_generate_follow_on_packets(MSFilter *f, EncState *s, mblk_t *frame, uint32_t timestamp, uint8_t *psc, uint8_t *end, bool_t last_packet){
mblk_t *packet;
int len=end-psc;
packet=dupb(frame);
packet=dupb(frame);
packet->b_rptr=psc;
packet->b_wptr=end;
/*ms_message("generating packet of size %i",end-psc);*/
rfc2429_set_P(psc,1);
mblk_set_timestamp_info(packet,timestamp);
if (len>s->mtu){
/*need to slit the packet using "follow-on" packets */
/*compute the number of packets need (rounded up)*/
......@@ -592,9 +595,9 @@ static void mjpeg_fragment_and_send(MSFilter *f,EncState *s,mblk_t *frame, uint3
struct jpeghdr_qtable qtblhdr;
int bytes_left = msgdsize(frame);
int data_len;
mblk_t *packet;
/* Initialize JPEG header
*/
//jpghdr.tspec = typespec;
......@@ -653,9 +656,9 @@ static void mjpeg_fragment_and_send(MSFilter *f,EncState *s,mblk_t *frame, uint3
mblk_set_marker_info(packet,TRUE);
}
memcpy(packet->b_wptr, frame->b_rptr + jpghdr.off, data_len);
memcpy(packet->b_wptr, frame->b_rptr + jpghdr.off, data_len);
packet->b_wptr=packet->b_wptr + data_len;
mblk_set_timestamp_info(packet,timestamp);
ms_queue_put(f->outputs[0],packet);
......@@ -687,7 +690,7 @@ static int find_marker(uint8_t **pbuf_ptr, uint8_t *buf_end){
static mblk_t *skip_jpeg_headers(mblk_t *full_frame, mblk_t **lqt, mblk_t **cqt){
int err;
uint8_t *pbuf_ptr=full_frame->b_rptr;
uint8_t *buf_end=full_frame->b_wptr;
uint8_t *buf_end=full_frame->b_wptr;
ms_message("image size: %li)", (long)(buf_end-pbuf_ptr));
......@@ -733,7 +736,7 @@ static void split_and_send(MSFilter *f, EncState *s, mblk_t *frame){
uint8_t *lastpsc;
uint8_t *psc;
uint32_t timestamp=f->ticker->time*90LL;
if (s->codec==CODEC_ID_MPEG4 || s->codec==CODEC_ID_SNOW)
{
mpeg4_fragment_and_send(f,s,frame,timestamp);
......@@ -775,7 +778,7 @@ static void split_and_send(MSFilter *f, EncState *s, mblk_t *frame){
static void process_frame(MSFilter *f, mblk_t *inm){
EncState *s=(EncState*)f->data;
AVFrame pict;
AVCodecContext *c=&s->av_context;
int error,got_packet;
mblk_t *comp_buf=s->comp_buf;
......@@ -786,18 +789,18 @@ static void process_frame(MSFilter *f, mblk_t *inm){
ms_yuv_buf_init_from_mblk(&yuv, inm);
/* convert image if necessary */
avcodec_get_frame_defaults(&pict);
avpicture_fill((AVPicture*)&pict,yuv.planes[0],c->pix_fmt,c->width,c->height);
avcodec_get_frame_defaults(s->pict);
avpicture_fill((AVPicture*)s->pict,yuv.planes[0],c->pix_fmt,c->width,c->height);
/* timestamp used by ffmpeg, unset here */
pict.pts=AV_NOPTS_VALUE;
s->pict->pts=AV_NOPTS_VALUE;
if (ms_video_starter_need_i_frame (&s->starter, f->ticker->time)){
/*sends an I frame at 2 seconds and 4 seconds after the beginning of the call*/
s->req_vfu=TRUE;
}
if (s->req_vfu){
pict.pict_type=FF_I_TYPE;
s->pict->pict_type=FF_I_TYPE;
s->req_vfu=FALSE;
}
comp_buf->b_rptr=comp_buf->b_wptr=comp_buf->b_datap->db_base;
......@@ -811,7 +814,7 @@ static void process_frame(MSFilter *f, mblk_t *inm){
packet.data=comp_buf->b_wptr;
packet.size=comp_buf_sz;
error=avcodec_encode_video2(c, &packet, &pict, &got_packet);
error=avcodec_encode_video2(c, &packet, s->pict, &got_packet);
if (error<0) ms_warning("ms_AVencoder_process: error %i.",error);
else if (got_packet){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment