Skip to content

Commit

Permalink
Replace remaining occurances of av_free_packet with av_packet_unref
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevcairiel committed Oct 27, 2015
1 parent 7f5af80 commit c2f861c
Show file tree
Hide file tree
Showing 59 changed files with 99 additions and 99 deletions.
2 changes: 1 addition & 1 deletion doc/examples/decoding_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static void audio_encode_example(const char *filename)
}
if (got_output) {
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
av_packet_unref(&pkt);
}
}

Expand Down
2 changes: 1 addition & 1 deletion doc/examples/demuxing_decoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ int main (int argc, char **argv)
pkt.data += ret;
pkt.size -= ret;
} while (pkt.size > 0);
av_free_packet(&orig_pkt);
av_packet_unref(&orig_pkt);
}

/* flush cached frames */
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/extract_mvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int main(int argc, char **argv)
pkt.data += ret;
pkt.size -= ret;
} while (pkt.size > 0);
av_free_packet(&orig_pkt);
av_packet_unref(&orig_pkt);
}

/* flush cached frames */
Expand Down
4 changes: 2 additions & 2 deletions doc/examples/filtering_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ int main(int argc, char **argv)
}

if (packet.size <= 0)
av_free_packet(&packet0);
av_packet_unref(&packet0);
} else {
/* discard non-wanted packets */
av_free_packet(&packet0);
av_packet_unref(&packet0);
}
}
end:
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/filtering_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ int main(int argc, char **argv)
av_frame_unref(frame);
}
}
av_free_packet(&packet);
av_packet_unref(&packet);
}
end:
avfilter_graph_free(&filter_graph);
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/remuxing.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Error muxing packet\n");
break;
}
av_free_packet(&pkt);
av_packet_unref(&pkt);
}

av_write_trailer(ofmt_ctx);
Expand Down
4 changes: 2 additions & 2 deletions doc/examples/transcoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ int main(int argc, char **argv)
if (ret < 0)
goto end;
}
av_free_packet(&packet);
av_packet_unref(&packet);
}

/* flush filters and encoders */
Expand All @@ -560,7 +560,7 @@ int main(int argc, char **argv)

av_write_trailer(ofmt_ctx);
end:
av_free_packet(&packet);
av_packet_unref(&packet);
av_frame_free(&frame);
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
avcodec_close(ifmt_ctx->streams[i]->codec);
Expand Down
14 changes: 7 additions & 7 deletions ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
*/
if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) {
if (ost->frame_number >= ost->max_frames) {
av_free_packet(pkt);
av_packet_unref(pkt);
return;
}
ost->frame_number++;
Expand Down Expand Up @@ -700,7 +700,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
if (a > 0) {
pkt->side_data = NULL;
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,
av_buffer_default_free, NULL, 0);
if (!new_pkt.buf)
Expand Down Expand Up @@ -777,7 +777,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
main_return_code = 1;
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)
Expand Down Expand Up @@ -1754,7 +1754,7 @@ static void flush_encoders(void)
break;
}
if (ost->finished & MUXER_FINISHED) {
av_free_packet(&pkt);
av_packet_unref(&pkt);
continue;
}
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
Expand Down Expand Up @@ -3521,7 +3521,7 @@ static void *input_thread(void *arg)
av_log(f->ctx, AV_LOG_ERROR,
"Unable to send packet to main thread: %s\n",
av_err2str(ret));
av_free_packet(&pkt);
av_packet_unref(&pkt);
av_thread_message_queue_set_err_recv(f->in_thread_queue, ret);
break;
}
Expand All @@ -3542,7 +3542,7 @@ static void free_input_threads(void)
continue;
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)
av_free_packet(&pkt);
av_packet_unref(&pkt);

pthread_join(f->thread, NULL);
f->joined = 1;
Expand Down Expand Up @@ -3945,7 +3945,7 @@ static int process_input(int file_index)
process_input_packet(ist, &pkt, 0);

discard_packet:
av_free_packet(&pkt);
av_packet_unref(&pkt);

return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions ffplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
SDL_UnlockMutex(q->mutex);

if (pkt != &flush_pkt && ret < 0)
av_free_packet(pkt);
av_packet_unref(pkt);

return ret;
}
Expand Down Expand Up @@ -472,7 +472,7 @@ static void packet_queue_flush(PacketQueue *q)
SDL_LockMutex(q->mutex);
for (pkt = q->first_pkt; pkt; pkt = pkt1) {
pkt1 = pkt->next;
av_free_packet(&pkt->pkt);
av_packet_unref(&pkt->pkt);
av_freep(&pkt);
}
q->last_pkt = NULL;
Expand Down Expand Up @@ -577,7 +577,7 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
d->next_pts_tb = d->start_pts_tb;
}
} 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->packet_pending = 1;
}
Expand Down Expand Up @@ -641,7 +641,7 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
}

static void decoder_destroy(Decoder *d) {
av_free_packet(&d->pkt);
av_packet_unref(&d->pkt);
}

static void frame_queue_unref_item(Frame *vp)
Expand Down Expand Up @@ -3119,7 +3119,7 @@ static int read_thread(void *arg)
} else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) {
packet_queue_put(&is->subtitleq, pkt);
} else {
av_free_packet(pkt);
av_packet_unref(pkt);
}
}

Expand Down
8 changes: 4 additions & 4 deletions ffserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,7 @@ static int http_prepare_data(HTTPContext *c)
c->packet_stream_index = pkt.stream_index;
ctx = c->rtp_ctx[c->packet_stream_index];
if(!ctx) {
av_free_packet(&pkt);
av_packet_unref(&pkt);
break;
}
codec = ctx->streams[0]->codec;
Expand Down Expand Up @@ -2370,11 +2370,11 @@ static int http_prepare_data(HTTPContext *c)

codec->frame_number++;
if (len == 0) {
av_free_packet(&pkt);
av_packet_unref(&pkt);
goto redo;
}
}
av_free_packet(&pkt);
av_packet_unref(&pkt);
}
}
break;
Expand Down Expand Up @@ -3548,7 +3548,7 @@ static void extract_mpeg4_header(AVFormatContext *infile)
}
mpeg4_count--;
}
av_free_packet(&pkt);
av_packet_unref(&pkt);
}
}

Expand Down
4 changes: 2 additions & 2 deletions libavcodec/avpacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
return 0;

failed_alloc:
av_free_packet(pkt);
av_packet_unref(pkt);
return AVERROR(ENOMEM);
}

Expand Down Expand Up @@ -342,7 +342,7 @@ int av_packet_merge_side_data(AVPacket *pkt){
bytestream_put_be64(&p, FF_MERGE_MARKER);
av_assert0(p-pkt->data == pkt->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 = NULL;
return 1;
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/libopusenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
discard_padding = opus->opts.packet_size - avpkt->duration;
// Check if subtraction resulted in an overflow
if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
av_free_packet(avpkt);
av_packet_unref(avpkt);
av_free(avpkt);
return AVERROR(EINVAL);
}
Expand All @@ -370,7 +370,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
AV_PKT_DATA_SKIP_SAMPLES,
10);
if(!side_data) {
av_free_packet(avpkt);
av_packet_unref(avpkt);
av_free(avpkt);
return AVERROR(ENOMEM);
}
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/libvpxenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
cx_frame->sz_alpha + 8);
if(!side_data) {
av_free_packet(pkt);
av_packet_unref(pkt);
av_free(pkt);
return AVERROR(ENOMEM);
}
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2353,7 +2353,7 @@ static int recode_subtitle(AVCodecContext *avctx,
ret = FFMIN(AVERROR(errno), -1);
av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" "
"from %s to UTF-8\n", inpkt->data, avctx->sub_charenc);
av_free_packet(&tmp);
av_packet_unref(&tmp);
goto end;
}
outpkt->size -= outl;
Expand Down Expand Up @@ -2460,7 +2460,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
pkt_recoded.side_data = NULL;
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)
sub->format = 0;
Expand Down
2 changes: 1 addition & 1 deletion libavdevice/decklink_dec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void avpacket_queue_flush(AVPacketQueue *q)
pthread_mutex_lock(&q->mutex);
for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
pkt1 = pkt->next;
av_free_packet(&pkt->pkt);
av_packet_unref(&pkt->pkt);
av_freep(&pkt);
}
q->last_pkt = NULL;
Expand Down
2 changes: 1 addition & 1 deletion libavdevice/dshow.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ dshow_read_close(AVFormatContext *s)
pktl = ctx->pktl;
while (pktl) {
AVPacketList *next = pktl->next;
av_free_packet(&pktl->pkt);
av_packet_unref(&pktl->pkt);
av_free(pktl);
pktl = next;
}
Expand Down
2 changes: 1 addition & 1 deletion libavdevice/openal-dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static int read_packet(AVFormatContext* ctx, AVPacket *pkt)
fail:
/* Handle failure */
if (pkt->data)
av_free_packet(pkt);
av_packet_unref(pkt);
if (error_msg)
av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg);
return error;
Expand Down
2 changes: 1 addition & 1 deletion libavfilter/lavfutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

end:
av_free_packet(&pkt);
av_packet_unref(&pkt);
avcodec_close(codec_ctx);
avformat_close_input(&format_ctx);
av_frame_free(&frame);
Expand Down
6 changes: 3 additions & 3 deletions libavfilter/src_movie.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
movie->out_index[pkt->stream_index];
if (pkt_out_id < 0) {
av_free_packet(&movie->pkt0);
av_packet_unref(&movie->pkt0);
pkt->size = 0; /* ready for next run */
pkt->data = NULL;
return 0;
Expand All @@ -517,7 +517,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
if (ret < 0) {
av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret));
av_frame_free(&frame);
av_free_packet(&movie->pkt0);
av_packet_unref(&movie->pkt0);
movie->pkt.size = 0;
movie->pkt.data = NULL;
return 0;
Expand All @@ -528,7 +528,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
pkt->data += ret;
pkt->size -= ret;
if (pkt->size <= 0) {
av_free_packet(&movie->pkt0);
av_packet_unref(&movie->pkt0);
pkt->size = 0; /* ready for next run */
pkt->data = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion libavfilter/vf_mcdeint.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
mcdeint->parity ^= 1;

end:
av_free_packet(&pkt);
av_packet_unref(&pkt);
av_frame_free(&inpic);
if (ret < 0) {
av_frame_free(&outpic);
Expand Down
2 changes: 1 addition & 1 deletion libavfilter/vf_subtitles.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
}
}
}
av_free_packet(&pkt);
av_packet_unref(&pkt);
avsubtitle_free(&sub);
}

Expand Down
2 changes: 1 addition & 1 deletion libavformat/adp.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int adp_read_packet(AVFormatContext *s, AVPacket *pkt)

if (ret != size) {
if (ret < 0) {
av_free_packet(pkt);
av_packet_unref(pkt);
return ret;
}
av_shrink_packet(pkt, ret);
Expand Down
2 changes: 1 addition & 1 deletion libavformat/aiffenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static int aiff_write_trailer(AVFormatContext *s)

while (pict_list) {
AVPacketList *next = pict_list->next;
av_free_packet(&pict_list->pkt);
av_packet_unref(&pict_list->pkt);
av_freep(&pict_list);
pict_list = next;
}
Expand Down
2 changes: 1 addition & 1 deletion libavformat/ape.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
if (ret < 0) {
av_free_packet(pkt);
av_packet_unref(pkt);
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion libavformat/apngenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
}
++apng->frame_number;

av_free_packet(apng->prev_packet);
av_packet_unref(apng->prev_packet);
if (packet)
av_copy_packet(apng->prev_packet, packet);
}
Expand Down
Loading

0 comments on commit c2f861c

Please sign in to comment.