encode: use new AVFrame API

This commit is contained in:
wm4 2014-03-16 12:57:14 +01:00
parent 62ab6a91bd
commit 62c88a52c4
2 changed files with 6 additions and 10 deletions

View File

@ -216,7 +216,6 @@ static int get_space(struct ao *ao)
// must get exactly ac->aframesize amount of data // must get exactly ac->aframesize amount of data
static int encode(struct ao *ao, double apts, void **data) static int encode(struct ao *ao, double apts, void **data)
{ {
AVFrame *frame;
AVPacket packet; AVPacket packet;
struct priv *ac = ao->priv; struct priv *ac = ao->priv;
struct encode_lavc_context *ectx = ao->encode_lavc_ctx; struct encode_lavc_context *ectx = ao->encode_lavc_ctx;
@ -232,9 +231,8 @@ static int encode(struct ao *ao, double apts, void **data)
av_init_packet(&packet); av_init_packet(&packet);
packet.data = ac->buffer; packet.data = ac->buffer;
packet.size = ac->buffer_size; packet.size = ac->buffer_size;
if(data) if(data) {
{ AVFrame *frame = av_frame_alloc();
frame = avcodec_alloc_frame();
frame->nb_samples = ac->aframesize; frame->nb_samples = ac->aframesize;
assert(ao->channels.num <= AV_NUM_DATA_POINTERS); assert(ao->channels.num <= AV_NUM_DATA_POINTERS);
@ -270,7 +268,7 @@ static int encode(struct ao *ao, double apts, void **data)
ac->savepts = frame->pts; ac->savepts = frame->pts;
} }
avcodec_free_frame(&frame); av_frame_free(&frame);
} }
else else
{ {

View File

@ -282,7 +282,6 @@ static void draw_image_unlocked(struct vo *vo, mp_image_t *mpi)
struct priv *vc = vo->priv; struct priv *vc = vo->priv;
struct encode_lavc_context *ectx = vo->encode_lavc_ctx; struct encode_lavc_context *ectx = vo->encode_lavc_ctx;
int size; int size;
AVFrame *frame;
AVCodecContext *avc; AVCodecContext *avc;
int64_t frameipts; int64_t frameipts;
double nextpts; double nextpts;
@ -407,7 +406,6 @@ static void draw_image_unlocked(struct vo *vo, mp_image_t *mpi)
} }
if (vc->lastipts != MP_NOPTS_VALUE) { if (vc->lastipts != MP_NOPTS_VALUE) {
frame = avcodec_alloc_frame();
// we have a valid image in lastimg // we have a valid image in lastimg
while (vc->lastipts < frameipts) { while (vc->lastipts < frameipts) {
@ -424,7 +422,7 @@ static void draw_image_unlocked(struct vo *vo, mp_image_t *mpi)
skipframes = 0; skipframes = 0;
if (thisduration > skipframes) { if (thisduration > skipframes) {
avcodec_get_frame_defaults(frame); AVFrame *frame = av_frame_alloc();
// this is a nop, unless the worst time base is the STREAM time base // this is a nop, unless the worst time base is the STREAM time base
frame->pts = av_rescale_q(vc->lastipts + skipframes, frame->pts = av_rescale_q(vc->lastipts + skipframes,
@ -444,12 +442,12 @@ static void draw_image_unlocked(struct vo *vo, mp_image_t *mpi)
write_packet(vo, size, &packet); write_packet(vo, size, &packet);
++vc->lastdisplaycount; ++vc->lastdisplaycount;
vc->lastencodedipts = vc->lastipts + skipframes; vc->lastencodedipts = vc->lastipts + skipframes;
av_frame_free(&frame);
} }
vc->lastipts += thisduration; vc->lastipts += thisduration;
} }
avcodec_free_frame(&frame);
} }
if (!mpi) { if (!mpi) {