avformat/dv: stop using av_init_packet()

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2021-05-02 10:13:38 -03:00
parent 7539a01bb0
commit 57aaeff523
1 changed files with 20 additions and 4 deletions

View File

@ -40,12 +40,22 @@
#include "dv.h"
#include "libavutil/avassert.h"
// Must be kept in sync with AVPacket
struct DVPacket {
int64_t pts;
uint8_t *data;
int size;
int stream_index;
int flags;
int64_t pos;
};
struct DVDemuxContext {
const AVDVProfile* sys; /* Current DV profile. E.g.: 525/60, 625/50 */
AVFormatContext* fctx;
AVStream* vst;
AVStream* ast[4];
AVPacket audio_pkt[4];
struct DVPacket audio_pkt[4];
uint8_t audio_buf[4][8192];
int ach;
int frames;
@ -261,11 +271,12 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame)
c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
av_init_packet(&c->audio_pkt[i]);
c->audio_pkt[i].size = 0;
c->audio_pkt[i].data = c->audio_buf[i];
c->audio_pkt[i].stream_index = c->ast[i]->index;
c->audio_pkt[i].flags |= AV_PKT_FLAG_KEY;
c->audio_pkt[i].pts = AV_NOPTS_VALUE;
c->audio_pkt[i].pos = -1;
}
c->ast[i]->codecpar->sample_rate = dv_audio_frequency[freq];
c->ast[i]->codecpar->channels = 2;
@ -358,7 +369,13 @@ int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt)
for (i = 0; i < c->ach; i++) {
if (c->ast[i] && c->audio_pkt[i].size) {
*pkt = c->audio_pkt[i];
pkt->size = c->audio_pkt[i].size;
pkt->data = c->audio_pkt[i].data;
pkt->stream_index = c->audio_pkt[i].stream_index;
pkt->flags = c->audio_pkt[i].flags;
pkt->pts = c->audio_pkt[i].pts;
pkt->pos = c->audio_pkt[i].pos;
c->audio_pkt[i].size = 0;
size = pkt->size;
break;
@ -404,7 +421,6 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
/* Now it's time to return video packet */
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->pos = pos;
pkt->size = size;