Replace remaining occurances of av_free_packet with av_packet_unref

This commit is contained in:
Hendrik Leppkes 2015-10-27 14:35:30 +01:00
parent 7f5af80ba4
commit c2f861ca42
59 changed files with 99 additions and 99 deletions

View File

@ -211,7 +211,7 @@ static void audio_encode_example(const char *filename)
} }
if (got_output) { if (got_output) {
fwrite(pkt.data, 1, pkt.size, f); fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt); av_packet_unref(&pkt);
} }
} }

View File

@ -326,7 +326,7 @@ int main (int argc, char **argv)
pkt.data += ret; pkt.data += ret;
pkt.size -= ret; pkt.size -= ret;
} while (pkt.size > 0); } while (pkt.size > 0);
av_free_packet(&orig_pkt); av_packet_unref(&orig_pkt);
} }
/* flush cached frames */ /* flush cached frames */

View File

@ -167,7 +167,7 @@ int main(int argc, char **argv)
pkt.data += ret; pkt.data += ret;
pkt.size -= ret; pkt.size -= ret;
} while (pkt.size > 0); } while (pkt.size > 0);
av_free_packet(&orig_pkt); av_packet_unref(&orig_pkt);
} }
/* flush cached frames */ /* flush cached frames */

View File

@ -273,10 +273,10 @@ int main(int argc, char **argv)
} }
if (packet.size <= 0) if (packet.size <= 0)
av_free_packet(&packet0); av_packet_unref(&packet0);
} else { } else {
/* discard non-wanted packets */ /* discard non-wanted packets */
av_free_packet(&packet0); av_packet_unref(&packet0);
} }
} }
end: end:

View File

@ -262,7 +262,7 @@ int main(int argc, char **argv)
av_frame_unref(frame); av_frame_unref(frame);
} }
} }
av_free_packet(&packet); av_packet_unref(&packet);
} }
end: end:
avfilter_graph_free(&filter_graph); avfilter_graph_free(&filter_graph);

View File

@ -143,7 +143,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Error muxing packet\n"); fprintf(stderr, "Error muxing packet\n");
break; break;
} }
av_free_packet(&pkt); av_packet_unref(&pkt);
} }
av_write_trailer(ofmt_ctx); av_write_trailer(ofmt_ctx);

View File

@ -536,7 +536,7 @@ int main(int argc, char **argv)
if (ret < 0) if (ret < 0)
goto end; goto end;
} }
av_free_packet(&packet); av_packet_unref(&packet);
} }
/* flush filters and encoders */ /* flush filters and encoders */
@ -560,7 +560,7 @@ int main(int argc, char **argv)
av_write_trailer(ofmt_ctx); av_write_trailer(ofmt_ctx);
end: end:
av_free_packet(&packet); av_packet_unref(&packet);
av_frame_free(&frame); av_frame_free(&frame);
for (i = 0; i < ifmt_ctx->nb_streams; i++) { for (i = 0; i < ifmt_ctx->nb_streams; i++) {
avcodec_close(ifmt_ctx->streams[i]->codec); avcodec_close(ifmt_ctx->streams[i]->codec);

View File

@ -653,7 +653,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
*/ */
if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) { if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) {
if (ost->frame_number >= ost->max_frames) { if (ost->frame_number >= ost->max_frames) {
av_free_packet(pkt); av_packet_unref(pkt);
return; return;
} }
ost->frame_number++; ost->frame_number++;
@ -700,7 +700,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
if (a > 0) { if (a > 0) {
pkt->side_data = NULL; pkt->side_data = NULL;
pkt->side_data_elems = 0; pkt->side_data_elems = 0;
av_free_packet(pkt); av_packet_unref(pkt);
new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
av_buffer_default_free, NULL, 0); av_buffer_default_free, NULL, 0);
if (!new_pkt.buf) if (!new_pkt.buf)
@ -777,7 +777,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
main_return_code = 1; main_return_code = 1;
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED);
} }
av_free_packet(pkt); av_packet_unref(pkt);
} }
static void close_output_stream(OutputStream *ost) static void close_output_stream(OutputStream *ost)
@ -1754,7 +1754,7 @@ static void flush_encoders(void)
break; break;
} }
if (ost->finished & MUXER_FINISHED) { if (ost->finished & MUXER_FINISHED) {
av_free_packet(&pkt); av_packet_unref(&pkt);
continue; continue;
} }
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
@ -3521,7 +3521,7 @@ static void *input_thread(void *arg)
av_log(f->ctx, AV_LOG_ERROR, av_log(f->ctx, AV_LOG_ERROR,
"Unable to send packet to main thread: %s\n", "Unable to send packet to main thread: %s\n",
av_err2str(ret)); av_err2str(ret));
av_free_packet(&pkt); av_packet_unref(&pkt);
av_thread_message_queue_set_err_recv(f->in_thread_queue, ret); av_thread_message_queue_set_err_recv(f->in_thread_queue, ret);
break; break;
} }
@ -3542,7 +3542,7 @@ static void free_input_threads(void)
continue; continue;
av_thread_message_queue_set_err_send(f->in_thread_queue, AVERROR_EOF); av_thread_message_queue_set_err_send(f->in_thread_queue, AVERROR_EOF);
while (av_thread_message_queue_recv(f->in_thread_queue, &pkt, 0) >= 0) while (av_thread_message_queue_recv(f->in_thread_queue, &pkt, 0) >= 0)
av_free_packet(&pkt); av_packet_unref(&pkt);
pthread_join(f->thread, NULL); pthread_join(f->thread, NULL);
f->joined = 1; f->joined = 1;
@ -3945,7 +3945,7 @@ static int process_input(int file_index)
process_input_packet(ist, &pkt, 0); process_input_packet(ist, &pkt, 0);
discard_packet: discard_packet:
av_free_packet(&pkt); av_packet_unref(&pkt);
return 0; return 0;
} }

View File

@ -432,7 +432,7 @@ static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
SDL_UnlockMutex(q->mutex); SDL_UnlockMutex(q->mutex);
if (pkt != &flush_pkt && ret < 0) if (pkt != &flush_pkt && ret < 0)
av_free_packet(pkt); av_packet_unref(pkt);
return ret; return ret;
} }
@ -472,7 +472,7 @@ static void packet_queue_flush(PacketQueue *q)
SDL_LockMutex(q->mutex); SDL_LockMutex(q->mutex);
for (pkt = q->first_pkt; pkt; pkt = pkt1) { for (pkt = q->first_pkt; pkt; pkt = pkt1) {
pkt1 = pkt->next; pkt1 = pkt->next;
av_free_packet(&pkt->pkt); av_packet_unref(&pkt->pkt);
av_freep(&pkt); av_freep(&pkt);
} }
q->last_pkt = NULL; q->last_pkt = NULL;
@ -577,7 +577,7 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
d->next_pts_tb = d->start_pts_tb; d->next_pts_tb = d->start_pts_tb;
} }
} while (pkt.data == flush_pkt.data || d->queue->serial != d->pkt_serial); } while (pkt.data == flush_pkt.data || d->queue->serial != d->pkt_serial);
av_free_packet(&d->pkt); av_packet_unref(&d->pkt);
d->pkt_temp = d->pkt = pkt; d->pkt_temp = d->pkt = pkt;
d->packet_pending = 1; d->packet_pending = 1;
} }
@ -641,7 +641,7 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
} }
static void decoder_destroy(Decoder *d) { static void decoder_destroy(Decoder *d) {
av_free_packet(&d->pkt); av_packet_unref(&d->pkt);
} }
static void frame_queue_unref_item(Frame *vp) static void frame_queue_unref_item(Frame *vp)
@ -3119,7 +3119,7 @@ static int read_thread(void *arg)
} else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) { } else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) {
packet_queue_put(&is->subtitleq, pkt); packet_queue_put(&is->subtitleq, pkt);
} else { } else {
av_free_packet(pkt); av_packet_unref(pkt);
} }
} }

View File

@ -2318,7 +2318,7 @@ static int http_prepare_data(HTTPContext *c)
c->packet_stream_index = pkt.stream_index; c->packet_stream_index = pkt.stream_index;
ctx = c->rtp_ctx[c->packet_stream_index]; ctx = c->rtp_ctx[c->packet_stream_index];
if(!ctx) { if(!ctx) {
av_free_packet(&pkt); av_packet_unref(&pkt);
break; break;
} }
codec = ctx->streams[0]->codec; codec = ctx->streams[0]->codec;
@ -2370,11 +2370,11 @@ static int http_prepare_data(HTTPContext *c)
codec->frame_number++; codec->frame_number++;
if (len == 0) { if (len == 0) {
av_free_packet(&pkt); av_packet_unref(&pkt);
goto redo; goto redo;
} }
} }
av_free_packet(&pkt); av_packet_unref(&pkt);
} }
} }
break; break;
@ -3548,7 +3548,7 @@ static void extract_mpeg4_header(AVFormatContext *infile)
} }
mpeg4_count--; mpeg4_count--;
} }
av_free_packet(&pkt); av_packet_unref(&pkt);
} }
} }

View File

@ -179,7 +179,7 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
return 0; return 0;
failed_alloc: failed_alloc:
av_free_packet(pkt); av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
@ -342,7 +342,7 @@ int av_packet_merge_side_data(AVPacket *pkt){
bytestream_put_be64(&p, FF_MERGE_MARKER); bytestream_put_be64(&p, FF_MERGE_MARKER);
av_assert0(p-pkt->data == pkt->size); av_assert0(p-pkt->data == pkt->size);
memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE); memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE);
av_free_packet(&old); av_packet_unref(&old);
pkt->side_data_elems = 0; pkt->side_data_elems = 0;
pkt->side_data = NULL; pkt->side_data = NULL;
return 1; return 1;

View File

@ -361,7 +361,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
discard_padding = opus->opts.packet_size - avpkt->duration; discard_padding = opus->opts.packet_size - avpkt->duration;
// Check if subtraction resulted in an overflow // Check if subtraction resulted in an overflow
if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) { if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
av_free_packet(avpkt); av_packet_unref(avpkt);
av_free(avpkt); av_free(avpkt);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
@ -370,7 +370,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
AV_PKT_DATA_SKIP_SAMPLES, AV_PKT_DATA_SKIP_SAMPLES,
10); 10);
if(!side_data) { if(!side_data) {
av_free_packet(avpkt); av_packet_unref(avpkt);
av_free(avpkt); av_free(avpkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }

View File

@ -733,7 +733,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
cx_frame->sz_alpha + 8); cx_frame->sz_alpha + 8);
if(!side_data) { if(!side_data) {
av_free_packet(pkt); av_packet_unref(pkt);
av_free(pkt); av_free(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }

View File

@ -2353,7 +2353,7 @@ static int recode_subtitle(AVCodecContext *avctx,
ret = FFMIN(AVERROR(errno), -1); ret = FFMIN(AVERROR(errno), -1);
av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" " av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" "
"from %s to UTF-8\n", inpkt->data, avctx->sub_charenc); "from %s to UTF-8\n", inpkt->data, avctx->sub_charenc);
av_free_packet(&tmp); av_packet_unref(&tmp);
goto end; goto end;
} }
outpkt->size -= outl; outpkt->size -= outl;
@ -2460,7 +2460,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
pkt_recoded.side_data = NULL; pkt_recoded.side_data = NULL;
pkt_recoded.side_data_elems = 0; pkt_recoded.side_data_elems = 0;
av_free_packet(&pkt_recoded); av_packet_unref(&pkt_recoded);
} }
if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)
sub->format = 0; sub->format = 0;

View File

@ -48,7 +48,7 @@ static void avpacket_queue_flush(AVPacketQueue *q)
pthread_mutex_lock(&q->mutex); pthread_mutex_lock(&q->mutex);
for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) { for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
pkt1 = pkt->next; pkt1 = pkt->next;
av_free_packet(&pkt->pkt); av_packet_unref(&pkt->pkt);
av_freep(&pkt); av_freep(&pkt);
} }
q->last_pkt = NULL; q->last_pkt = NULL;

View File

@ -119,7 +119,7 @@ dshow_read_close(AVFormatContext *s)
pktl = ctx->pktl; pktl = ctx->pktl;
while (pktl) { while (pktl) {
AVPacketList *next = pktl->next; AVPacketList *next = pktl->next;
av_free_packet(&pktl->pkt); av_packet_unref(&pktl->pkt);
av_free(pktl); av_free(pktl);
pktl = next; pktl = next;
} }

View File

@ -204,7 +204,7 @@ static int read_packet(AVFormatContext* ctx, AVPacket *pkt)
fail: fail:
/* Handle failure */ /* Handle failure */
if (pkt->data) if (pkt->data)
av_free_packet(pkt); av_packet_unref(pkt);
if (error_msg) if (error_msg)
av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg); av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg);
return error; return error;

View File

@ -95,7 +95,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h); av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h);
end: end:
av_free_packet(&pkt); av_packet_unref(&pkt);
avcodec_close(codec_ctx); avcodec_close(codec_ctx);
avformat_close_input(&format_ctx); avformat_close_input(&format_ctx);
av_frame_free(&frame); av_frame_free(&frame);

View File

@ -490,7 +490,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 : pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 :
movie->out_index[pkt->stream_index]; movie->out_index[pkt->stream_index];
if (pkt_out_id < 0) { if (pkt_out_id < 0) {
av_free_packet(&movie->pkt0); av_packet_unref(&movie->pkt0);
pkt->size = 0; /* ready for next run */ pkt->size = 0; /* ready for next run */
pkt->data = NULL; pkt->data = NULL;
return 0; return 0;
@ -517,7 +517,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
if (ret < 0) { if (ret < 0) {
av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret)); av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret));
av_frame_free(&frame); av_frame_free(&frame);
av_free_packet(&movie->pkt0); av_packet_unref(&movie->pkt0);
movie->pkt.size = 0; movie->pkt.size = 0;
movie->pkt.data = NULL; movie->pkt.data = NULL;
return 0; return 0;
@ -528,7 +528,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
pkt->data += ret; pkt->data += ret;
pkt->size -= ret; pkt->size -= ret;
if (pkt->size <= 0) { if (pkt->size <= 0) {
av_free_packet(&movie->pkt0); av_packet_unref(&movie->pkt0);
pkt->size = 0; /* ready for next run */ pkt->size = 0; /* ready for next run */
pkt->data = NULL; pkt->data = NULL;
} }

View File

@ -277,7 +277,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
mcdeint->parity ^= 1; mcdeint->parity ^= 1;
end: end:
av_free_packet(&pkt); av_packet_unref(&pkt);
av_frame_free(&inpic); av_frame_free(&inpic);
if (ret < 0) { if (ret < 0) {
av_frame_free(&outpic); av_frame_free(&outpic);

View File

@ -444,7 +444,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
} }
} }
} }
av_free_packet(&pkt); av_packet_unref(&pkt);
avsubtitle_free(&sub); avsubtitle_free(&sub);
} }

View File

@ -78,7 +78,7 @@ static int adp_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ret != size) { if (ret != size) {
if (ret < 0) { if (ret < 0) {
av_free_packet(pkt); av_packet_unref(pkt);
return ret; return ret;
} }
av_shrink_packet(pkt, ret); av_shrink_packet(pkt, ret);

View File

@ -293,7 +293,7 @@ static int aiff_write_trailer(AVFormatContext *s)
while (pict_list) { while (pict_list) {
AVPacketList *next = pict_list->next; AVPacketList *next = pict_list->next;
av_free_packet(&pict_list->pkt); av_packet_unref(&pict_list->pkt);
av_freep(&pict_list); av_freep(&pict_list);
pict_list = next; pict_list = next;
} }

View File

@ -418,7 +418,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip); AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size); ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
if (ret < 0) { if (ret < 0) {
av_free_packet(pkt); av_packet_unref(pkt);
return ret; return ret;
} }

View File

@ -192,7 +192,7 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
} }
++apng->frame_number; ++apng->frame_number;
av_free_packet(apng->prev_packet); av_packet_unref(apng->prev_packet);
if (packet) if (packet)
av_copy_packet(apng->prev_packet, packet); av_copy_packet(apng->prev_packet, packet);
} }

View File

@ -298,7 +298,7 @@ static int asf_read_picture(AVFormatContext *s, int len)
fail: fail:
av_freep(&desc); av_freep(&desc);
av_free_packet(&pkt); av_packet_unref(&pkt);
return ret; return ret;
} }
@ -852,7 +852,7 @@ static int asf_read_header(AVFormatContext *s)
if ((ret = av_get_packet(pb, &pkt, len)) < 0) if ((ret = av_get_packet(pb, &pkt, len)) < 0)
return ret; return ret;
av_hex_dump_log(s, AV_LOG_DEBUG, pkt.data, pkt.size); av_hex_dump_log(s, AV_LOG_DEBUG, pkt.data, pkt.size);
av_free_packet(&pkt); av_packet_unref(&pkt);
len= avio_rl32(pb); len= avio_rl32(pb);
get_tag(s, "ASF_Protection_Type", -1, len, 32); get_tag(s, "ASF_Protection_Type", -1, len, 32);
len= avio_rl32(pb); len= avio_rl32(pb);
@ -1288,7 +1288,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
"freeing incomplete packet size %d, new %d\n", "freeing incomplete packet size %d, new %d\n",
asf_st->pkt.size, asf_st->packet_obj_size); asf_st->pkt.size, asf_st->packet_obj_size);
asf_st->frag_offset = 0; asf_st->frag_offset = 0;
av_free_packet(&asf_st->pkt); av_packet_unref(&asf_st->pkt);
} }
/* new packet */ /* new packet */
if ((ret = av_new_packet(&asf_st->pkt, asf_st->packet_obj_size)) < 0) if ((ret = av_new_packet(&asf_st->pkt, asf_st->packet_obj_size)) < 0)
@ -1379,7 +1379,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
if (i == asf_st->pkt.size) { if (i == asf_st->pkt.size) {
av_log(s, AV_LOG_DEBUG, "discarding ms fart\n"); av_log(s, AV_LOG_DEBUG, "discarding ms fart\n");
asf_st->frag_offset = 0; asf_st->frag_offset = 0;
av_free_packet(&asf_st->pkt); av_packet_unref(&asf_st->pkt);
continue; continue;
} }
} }
@ -1476,7 +1476,7 @@ static void asf_reset_header(AVFormatContext *s)
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
asf_st = &asf->streams[i]; asf_st = &asf->streams[i];
av_free_packet(&asf_st->pkt); av_packet_unref(&asf_st->pkt);
asf_st->packet_obj_size = 0; asf_st->packet_obj_size = 0;
asf_st->frag_offset = 0; asf_st->frag_offset = 0;
asf_st->seq = 0; asf_st->seq = 0;
@ -1538,7 +1538,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index,
pts = pkt->dts; pts = pkt->dts;
av_free_packet(pkt); av_packet_unref(pkt);
if (pkt->flags & AV_PKT_FLAG_KEY) { if (pkt->flags & AV_PKT_FLAG_KEY) {
i = pkt->stream_index; i = pkt->stream_index;

View File

@ -1496,7 +1496,7 @@ resync:
} }
if (!avi->non_interleaved && pkt->pos >= 0 && ast->seek_pos > pkt->pos) { if (!avi->non_interleaved && pkt->pos >= 0 && ast->seek_pos > pkt->pos) {
av_free_packet(pkt); av_packet_unref(pkt);
goto resync; goto resync;
} }
ast->seek_pos= 0; ast->seek_pos= 0;

View File

@ -412,7 +412,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
dst += size; dst += size;
avio_skip(s->pb, skip); avio_skip(s->pb, skip);
if (ret != size) { if (ret != size) {
av_free_packet(pkt); av_packet_unref(pkt);
break; break;
} }
} }

View File

@ -511,7 +511,7 @@ static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
ret = 1; ret = 1;
} }
if (ret > 0) { if (ret > 0) {
av_free_packet(pkt); av_packet_unref(pkt);
pkt2.buf = av_buffer_create(pkt2.data, pkt2.size, pkt2.buf = av_buffer_create(pkt2.data, pkt2.size,
av_buffer_default_free, NULL, 0); av_buffer_default_free, NULL, 0);
if (!pkt2.buf) { if (!pkt2.buf) {

View File

@ -612,7 +612,7 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
if (partial_packet) { if (partial_packet) {
avpriv_request_sample(s, "video header followed by audio packet"); avpriv_request_sample(s, "video header followed by audio packet");
av_free_packet(pkt); av_packet_unref(pkt);
partial_packet = 0; partial_packet = 0;
} }
@ -736,7 +736,7 @@ get_video_packet:
} }
if (ret < 0 && partial_packet) if (ret < 0 && partial_packet)
av_free_packet(pkt); av_packet_unref(pkt);
return ret; return ret;
} }

View File

@ -632,7 +632,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = ffm->header[0]; pkt->stream_index = ffm->header[0];
if ((unsigned)pkt->stream_index >= s->nb_streams) { if ((unsigned)pkt->stream_index >= s->nb_streams) {
av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index); av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index);
av_free_packet(pkt); av_packet_unref(pkt);
ffm->read_state = READ_HEADER; ffm->read_state = READ_HEADER;
return -1; return -1;
} }
@ -643,7 +643,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
ffm->read_state = READ_HEADER; ffm->read_state = READ_HEADER;
if (ffm_read_data(s, pkt->data, size, 0) != size) { if (ffm_read_data(s, pkt->data, size, 0) != size) {
/* bad case: desynchronized packet. we cancel all the packet loading */ /* bad case: desynchronized packet. we cancel all the packet loading */
av_free_packet(pkt); av_packet_unref(pkt);
return -1; return -1;
} }
pkt->pts = AV_RB64(ffm->header+8); pkt->pts = AV_RB64(ffm->header+8);

View File

@ -267,7 +267,7 @@ static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_inde
&out_pkt.data, &out_pkt.size, pkt.data, pkt.size, &out_pkt.data, &out_pkt.size, pkt.data, pkt.size,
pkt.pts, pkt.dts, *ppos); pkt.pts, pkt.dts, *ppos);
av_free_packet(&pkt); av_packet_unref(&pkt);
if (out_pkt.size){ if (out_pkt.size){
int size = out_pkt.size; int size = out_pkt.size;
if (parser->pts != AV_NOPTS_VALUE){ if (parser->pts != AV_NOPTS_VALUE){

View File

@ -1143,7 +1143,7 @@ leave:
av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d\n", last, orig_size + 11); av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d\n", last, orig_size + 11);
avio_seek(s->pb, pos + 1, SEEK_SET); avio_seek(s->pb, pos + 1, SEEK_SET);
ret = resync(s); ret = resync(s);
av_free_packet(pkt); av_packet_unref(pkt);
if (ret >= 0) { if (ret >= 0) {
goto retry; goto retry;
} }

View File

@ -173,7 +173,7 @@ static int flush_packet(AVFormatContext *s, AVPacket *new)
avio_write(pb, pkt->data, pkt->size); avio_write(pb, pkt->data, pkt->size);
av_free_packet(gif->prev_pkt); av_packet_unref(gif->prev_pkt);
if (new) if (new)
av_copy_packet(gif->prev_pkt, new); av_copy_packet(gif->prev_pkt, new);

View File

@ -738,7 +738,7 @@ static int iff_read_packet(AVFormatContext *s,
bytestream_put_be16(&buf, 2); bytestream_put_be16(&buf, 2);
ret = avio_read(pb, buf, iff->body_size); ret = avio_read(pb, buf, iff->body_size);
if (ret<0) { if (ret<0) {
av_free_packet(pkt); av_packet_unref(pkt);
} else if (ret < iff->body_size) } else if (ret < iff->body_size)
av_shrink_packet(pkt, ret + 2); av_shrink_packet(pkt, ret + 2);
} else { } else {

View File

@ -157,11 +157,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
(ret = avformat_write_header(fmt, NULL)) < 0 || (ret = avformat_write_header(fmt, NULL)) < 0 ||
(ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 || (ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 ||
(ret = av_write_trailer(fmt)) < 0) { (ret = av_write_trailer(fmt)) < 0) {
av_free_packet(&pkt2); av_packet_unref(&pkt2);
avformat_free_context(fmt); avformat_free_context(fmt);
return ret; return ret;
} }
av_free_packet(&pkt2); av_packet_unref(&pkt2);
avformat_free_context(fmt); avformat_free_context(fmt);
} else { } else {
avio_write(pb[0], pkt->data, pkt->size); avio_write(pb[0], pkt->data, pkt->size);

View File

@ -325,7 +325,7 @@ static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->size = ModPlug_Read(modplug->f, pkt->data, AUDIO_PKT_SIZE); pkt->size = ModPlug_Read(modplug->f, pkt->data, AUDIO_PKT_SIZE);
if (pkt->size <= 0) { if (pkt->size <= 0) {
av_free_packet(pkt); av_packet_unref(pkt);
return pkt->size == 0 ? AVERROR_EOF : AVERROR(EIO); return pkt->size == 0 ? AVERROR_EOF : AVERROR(EIO);
} }
return 0; return 0;

View File

@ -2750,7 +2750,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
additional_size + 8); additional_size + 8);
if (!side_data) { if (!side_data) {
av_free_packet(pkt); av_packet_unref(pkt);
av_free(pkt); av_free(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
@ -2763,7 +2763,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
AV_PKT_DATA_SKIP_SAMPLES, AV_PKT_DATA_SKIP_SAMPLES,
10); 10);
if (!side_data) { if (!side_data) {
av_free_packet(pkt); av_packet_unref(pkt);
av_free(pkt); av_free(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }

View File

@ -440,10 +440,10 @@ concatenate:
return ret; return ret;
if (info->num_blocks != 6) if (info->num_blocks != 6)
return 0; return 0;
av_free_packet(pkt); av_packet_unref(pkt);
if ((ret = av_copy_packet(pkt, &info->pkt)) < 0) if ((ret = av_copy_packet(pkt, &info->pkt)) < 0)
return ret; return ret;
av_free_packet(&info->pkt); av_packet_unref(&info->pkt);
info->num_blocks = 0; info->num_blocks = 0;
} }
@ -498,7 +498,7 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track)
av_free(buf); av_free(buf);
end: end:
av_free_packet(&info->pkt); av_packet_unref(&info->pkt);
av_freep(&track->eac3_priv); av_freep(&track->eac3_priv);
return size; return size;
@ -4606,7 +4606,7 @@ static int mov_write_subtitle_end_packet(AVFormatContext *s,
end.stream_index = stream_index; end.stream_index = stream_index;
ret = mov_write_single_packet(s, &end); ret = mov_write_single_packet(s, &end);
av_free_packet(&end); av_packet_unref(&end);
return ret; return ret;
} }

View File

@ -956,12 +956,12 @@ static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = idx_pkt.pos; pkt->pos = idx_pkt.pos;
pkt->stream_index = idx_pkt.stream_index; pkt->stream_index = idx_pkt.stream_index;
av_free_packet(&idx_pkt); av_packet_unref(&idx_pkt);
return 0; return 0;
fail: fail:
av_free_packet(pkt); av_packet_unref(pkt);
av_free_packet(&idx_pkt); av_packet_unref(&idx_pkt);
return ret; return ret;
} }

View File

@ -2654,7 +2654,7 @@ static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt)
ts->pkt = pkt; ts->pkt = pkt;
ret = handle_packets(ts, 0); ret = handle_packets(ts, 0);
if (ret < 0) { if (ret < 0) {
av_free_packet(ts->pkt); av_packet_unref(ts->pkt);
/* flush pes data left */ /* flush pes data left */
for (i = 0; i < NB_PID_MAX; i++) for (i = 0; i < NB_PID_MAX; i++)
if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) { if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) {
@ -2743,7 +2743,7 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
ret = av_read_frame(s, &pkt); ret = av_read_frame(s, &pkt);
if (ret < 0) if (ret < 0)
return AV_NOPTS_VALUE; return AV_NOPTS_VALUE;
av_free_packet(&pkt); av_packet_unref(&pkt);
if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0) { if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0) {
ff_reduce_index(s, pkt.stream_index); ff_reduce_index(s, pkt.stream_index);
av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);

View File

@ -1157,7 +1157,7 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code)
return 0; return 0;
fail: fail:
av_free_packet(pkt); av_packet_unref(pkt);
return ret; return ret;
} }

View File

@ -844,7 +844,7 @@ retry:
return psize; return psize;
fail: fail:
av_free_packet(pkt); av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }

View File

@ -148,7 +148,7 @@ static int redspark_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(s->pb, pkt, size); ret = av_get_packet(s->pb, pkt, size);
if (ret != size) { if (ret != size) {
av_free_packet(pkt); av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }

View File

@ -783,7 +783,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
AV_WL32(pkt->data + 1, 1); AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0); AV_WL32(pkt->data + 5, 0);
if ((ret = avio_read(pb, pkt->data + 9, len)) != len) { if ((ret = avio_read(pb, pkt->data + 9, len)) != len) {
av_free_packet(pkt); av_packet_unref(pkt);
av_log(s, AV_LOG_ERROR, "Failed to read %d bytes\n", len); av_log(s, AV_LOG_ERROR, "Failed to read %d bytes\n", len);
return ret < 0 ? ret : AVERROR(EIO); return ret < 0 ? ret : AVERROR(EIO);
} }

View File

@ -95,7 +95,7 @@ static int sdr2_read_packet(AVFormatContext *s, AVPacket *pkt)
memcpy(pkt->data, header, 24); memcpy(pkt->data, header, 24);
ret = avio_read(s->pb, pkt->data + 24, next - 52); ret = avio_read(s->pb, pkt->data + 24, next - 52);
if (ret < 0) { if (ret < 0) {
av_free_packet(pkt); av_packet_unref(pkt);
return ret; return ret;
} }
av_shrink_packet(pkt, ret + 24); av_shrink_packet(pkt, ret + 24);

View File

@ -219,7 +219,7 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
if (c->gmcsize) if (c->gmcsize)
memcpy(pkt->data + 2, c->gmc, c->gmcsize); memcpy(pkt->data + 2, c->gmc, c->gmcsize);
if (avio_read(s->pb, pkt->data + 2 + c->gmcsize, size) != size) { if (avio_read(s->pb, pkt->data + 2 + c->gmcsize, size) != size) {
av_free_packet(pkt); av_packet_unref(pkt);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
pkt->stream_index = 0; pkt->stream_index = 0;

View File

@ -179,7 +179,7 @@ static void drop_dups(void *log_ctx, FFDemuxSubtitlesQueue *q)
q->subs[i].stream_index == last->stream_index && q->subs[i].stream_index == last->stream_index &&
!strcmp(q->subs[i].data, last->data)) { !strcmp(q->subs[i].data, last->data)) {
av_free_packet(&q->subs[i]); av_packet_unref(&q->subs[i]);
drop++; drop++;
} else if (drop) { } else if (drop) {
q->subs[last_id + 1] = q->subs[i]; q->subs[last_id + 1] = q->subs[i];
@ -302,7 +302,7 @@ void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q)
int i; int i;
for (i = 0; i < q->nb_subs; i++) for (i = 0; i < q->nb_subs; i++)
av_free_packet(&q->subs[i]); av_packet_unref(&q->subs[i]);
av_freep(&q->subs); av_freep(&q->subs);
q->nb_subs = q->allocated_size = q->current_sub_idx = 0; q->nb_subs = q->allocated_size = q->current_sub_idx = 0;
} }

View File

@ -479,7 +479,7 @@ bitmap_end_skip:
if ((res = av_new_packet(pkt, len)) < 0) if ((res = av_new_packet(pkt, len)) < 0)
return res; return res;
if (avio_read(pb, pkt->data, 4) != 4) { if (avio_read(pb, pkt->data, 4) != 4) {
av_free_packet(pkt); av_packet_unref(pkt);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (AV_RB32(pkt->data) == 0xffd8ffd9 || if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
@ -496,7 +496,7 @@ bitmap_end_skip:
} }
if (res != pkt->size) { if (res != pkt->size) {
if (res < 0) { if (res < 0) {
av_free_packet(pkt); av_packet_unref(pkt);
return res; return res;
} }
av_shrink_packet(pkt, res); av_shrink_packet(pkt, res);

View File

@ -424,7 +424,7 @@ static int filter_packet(void *log_ctx, AVPacket *pkt,
} }
if (ret > 0) { if (ret > 0) {
av_free_packet(pkt); av_packet_unref(pkt);
new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
av_buffer_default_free, NULL, 0); av_buffer_default_free, NULL, 0);
if (!new_pkt.buf) if (!new_pkt.buf)

View File

@ -1403,7 +1403,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
if (pkt->flags & AV_PKT_FLAG_KEY) if (pkt->flags & AV_PKT_FLAG_KEY)
st->skip_to_keyframe = 0; st->skip_to_keyframe = 0;
if (st->skip_to_keyframe) { if (st->skip_to_keyframe) {
av_free_packet(&cur_pkt); av_packet_unref(&cur_pkt);
if (got_packet) { if (got_packet) {
*pkt = cur_pkt; *pkt = cur_pkt;
} }

View File

@ -298,7 +298,7 @@ restart:
fail: fail:
if (ret < 0) if (ret < 0)
av_free_packet(pkt); av_packet_unref(pkt);
return ret; return ret;
} }

View File

@ -140,7 +140,7 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts)
avio_w8(s->pb, 0); avio_w8(s->pb, 0);
} }
avio_write(s->pb, w->last_pkt.data + skip, w->last_pkt.size - skip); avio_write(s->pb, w->last_pkt.data + skip, w->last_pkt.size - skip);
av_free_packet(&w->last_pkt); av_packet_unref(&w->last_pkt);
} }
return 0; return 0;

View File

@ -826,7 +826,7 @@ static int write_trailer(AVFormatContext *s)
av_free(wctx->sp_pairs); av_free(wctx->sp_pairs);
av_free(wctx->st_pairs); av_free(wctx->st_pairs);
av_free_packet(&wctx->thumbnail); av_packet_unref(&wctx->thumbnail);
return 0; return 0;
} }

View File

@ -190,12 +190,12 @@ static int video_decode(const char *input_filename)
return -1; return -1;
} }
} }
av_free_packet(&pkt); av_packet_unref(&pkt);
av_init_packet(&pkt); av_init_packet(&pkt);
} }
} while (!end_of_stream || got_frame); } while (!end_of_stream || got_frame);
av_free_packet(&pkt); av_packet_unref(&pkt);
av_frame_free(&fr); av_frame_free(&fr);
avcodec_close(ctx); avcodec_close(ctx);
avformat_close_input(&fmt_ctx); avformat_close_input(&fmt_ctx);

View File

@ -206,7 +206,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,
out_offset += out_frame_bytes; out_offset += out_frame_bytes;
} }
} }
av_free_packet(&enc_pkt); av_packet_unref(&enc_pkt);
} }
if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_FRAMES) != 0) { if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_FRAMES) != 0) {

View File

@ -134,13 +134,13 @@ static int video_decode_example(const char *input_filename)
fr->pkt_pts, fr->pkt_dts, av_frame_get_pkt_duration(fr), fr->pkt_pts, fr->pkt_dts, av_frame_get_pkt_duration(fr),
number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes)); number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes));
} }
av_free_packet(&pkt); av_packet_unref(&pkt);
av_init_packet(&pkt); av_init_packet(&pkt);
} }
i++; i++;
} while (!end_of_stream || got_frame); } while (!end_of_stream || got_frame);
av_free_packet(&pkt); av_packet_unref(&pkt);
av_frame_free(&fr); av_frame_free(&fr);
avcodec_close(ctx); avcodec_close(ctx);
avformat_close_input(&fmt_ctx); avformat_close_input(&fmt_ctx);

View File

@ -143,11 +143,11 @@ static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream,
} }
} }
} }
av_free_packet(&pkt); av_packet_unref(&pkt);
av_init_packet(&pkt); av_init_packet(&pkt);
} while ((!end_of_stream || got_frame) && (no_seeking || (fr->pkt_pts + av_frame_get_pkt_duration(fr) <= ts_end))); } while ((!end_of_stream || got_frame) && (no_seeking || (fr->pkt_pts + av_frame_get_pkt_duration(fr) <= ts_end)));
av_free_packet(&pkt); av_packet_unref(&pkt);
av_freep(&byte_buffer); av_freep(&byte_buffer);
return 0; return 0;

View File

@ -87,7 +87,7 @@ int main(int argc, char **argv)
ret, packet.size, packet.stream_index, ret, packet.size, packet.stream_index,
av_ts2str(packet.dts), av_ts2timestr(packet.dts, tb), av_ts2str(packet.dts), av_ts2timestr(packet.dts, tb),
av_ts2str(packet.pts), av_ts2timestr(packet.pts, tb)); av_ts2str(packet.pts), av_ts2timestr(packet.pts, tb));
av_free_packet(&packet); av_packet_unref(&packet);
} }
} else if (sscanf(*argv, "seek:%i:%"SCNi64":%"SCNi64":%"SCNi64":%i", } else if (sscanf(*argv, "seek:%i:%"SCNi64":%"SCNi64":%"SCNi64":%i",
&stream, &min_ts, &ts, &max_ts, &flags) == 5) { &stream, &min_ts, &ts, &max_ts, &flags) == 5) {