*/
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++;
pkt->data, pkt->size,
pkt->flags & AV_PKT_FLAG_KEY);
if (a > 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)
pthread_mutex_lock(&f->fifo_lock);
while (av_fifo_size(f->fifo)) {
av_fifo_generic_read(f->fifo, &pkt, sizeof(pkt), NULL);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
}
pthread_cond_signal(&f->fifo_cond);
pthread_mutex_unlock(&f->fifo_lock);
while (av_fifo_size(f->fifo)) {
av_fifo_generic_read(f->fifo, &pkt, sizeof(pkt), NULL);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
}
av_fifo_free(f->fifo);
}
process_input_packet(ist, &pkt, 0);
discard_packet:
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
return 0;
}
SDL_LockMutex(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;
while (is->paused && !is->videoq.abort_request)
SDL_Delay(10);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
ret = get_video_frame(is, frame, &pts_int, &pkt);
if (ret < 0)
av_freep(&vfilters);
avfilter_graph_free(&graph);
#endif
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
av_frame_free(&frame);
return 0;
}
is->subpq_size++;
SDL_UnlockMutex(is->subpq_mutex);
}
- av_free_packet(pkt);
+ av_packet_unref(pkt);
}
return 0;
}
/* free the current packet */
if (pkt->data)
- av_free_packet(pkt);
+ av_packet_unref(pkt);
memset(pkt_temp, 0, sizeof(*pkt_temp));
if (is->paused || is->audioq.abort_request) {
SDL_CloseAudio();
packet_queue_end(&is->audioq);
- av_free_packet(&is->audio_pkt);
+ av_packet_unref(&is->audio_pkt);
if (is->avr)
avresample_free(&is->avr);
av_freep(&is->audio_buf1);
} 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);
}
}
/* wait until the end */
API changes, most recent first:
+2015-xx-xx - xxxxxxx - lavc 57.7.0 - avcodec.h
+ Deprecate av_free_packet(). Use av_packet_unref() as replacement,
+ it resets the packet in a more consistent way.
+
2015-xx-xx - xxxxxxx - lavc 57.5.0 - avcodec.h
Add data and linesize array to AVSubtitleRect, to be used instead of
the ones from the embedded AVPicture.
}
if (got_output) {
fwrite(pkt.data, 1, pkt.size, f);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
}
}
fclose(f);
if (got_output) {
printf("encoding frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
}
}
if (got_output) {
printf("encoding frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
}
}
data_present, &input_packet)) < 0) {
fprintf(stderr, "Could not decode frame (error '%s')\n",
get_error_text(error));
- av_free_packet(&input_packet);
+ av_packet_unref(&input_packet);
return error;
}
*/
if (*finished && *data_present)
*finished = 0;
- av_free_packet(&input_packet);
+ av_packet_unref(&input_packet);
return 0;
}
frame, data_present)) < 0) {
fprintf(stderr, "Could not encode frame (error '%s')\n",
get_error_text(error));
- av_free_packet(&output_packet);
+ av_packet_unref(&output_packet);
return error;
}
if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {
fprintf(stderr, "Could not write frame (error '%s')\n",
get_error_text(error));
- av_free_packet(&output_packet);
+ av_packet_unref(&output_packet);
return error;
}
- av_free_packet(&output_packet);
+ av_packet_unref(&output_packet);
}
return 0;
* ABI. Thus it may be allocated on stack and no new fields can be added to it
* without libavcodec and libavformat major bump.
*
- * The semantics of data ownership depends on the buf or destruct (deprecated)
- * fields. If either is set, the packet data is dynamically allocated and is
- * valid indefinitely until av_free_packet() is called (which in turn calls
- * av_buffer_unref()/the destruct callback to free the data). If neither is set,
- * the packet data is typically backed by some static buffer somewhere and is
- * only valid for a limited time (e.g. until the next read call when demuxing).
+ * The semantics of data ownership depends on the buf field.
+ * If it is set, the packet data is dynamically allocated and is
+ * valid indefinitely until a call to av_packet_unref() reduces the
+ * reference count to 0.
*
- * The side data is always allocated with av_malloc() and is freed in
- * av_free_packet().
+ * If the buf field is not set av_packet_ref() would make a copy instead
+ * of increasing the reference count.
+ *
+ * The side data is always allocated with av_malloc(), copied by
+ * av_packet_ref() and freed by av_packet_unref().
+ *
+ * @see av_packet_ref
+ * @see av_packet_unref
*/
typedef struct AVPacket {
/**
* packet is allocated if it was not really allocated.
*/
int av_dup_packet(AVPacket *pkt);
-
+#if FF_API_AVPACKET_OLD_API
/**
* Free a packet.
*
+ * @deprecated Use av_packet_unref
+ *
* @param pkt packet to free
*/
+attribute_deprecated
void av_free_packet(AVPacket *pkt);
-
+#endif
/**
* Allocate new information of a packet.
*
* output packet.
*
* If this function fails or produces no output, avpkt will be
- * freed using av_free_packet() (i.e. avpkt->destruct will be
- * called to free the user supplied buffer).
+ * freed using av_packet_unref().
* @param[in] frame AVFrame containing the raw audio data to be encoded.
* May be NULL when flushing an encoder that has the
* AV_CODEC_CAP_DELAY capability set.
* caller, he is responsible for freeing it.
*
* If this function fails or produces no output, avpkt will be
- * freed using av_free_packet() (i.e. avpkt->destruct will be
- * called to free the user supplied buffer).
+ * freed using av_packet_unref().
* @param[in] frame AVFrame containing the raw video data to be encoded.
* May be NULL when flushing an encoder that has the
* AV_CODEC_CAP_DELAY capability set.
return 0;
failed_alloc:
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
pkt->side_data_elems = 0;
}
+#if FF_API_AVPACKET_OLD_API
+FF_DISABLE_DEPRECATION_WARNINGS
void av_free_packet(AVPacket *pkt)
{
if (pkt) {
av_packet_free_side_data(pkt);
}
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
int size)
return 0;
memfail:
- av_free_packet(pkt);
+ av_packet_unref(pkt);
av_freep(&buf2);
av_freep(&state);
av_freep(&zero);
return 0;
} else {
if (!user_packet)
- av_free_packet(pkt);
+ av_packet_unref(pkt);
if (!xerr)
return 0;
av_log(avctx, AV_LOG_ERROR,
return ret;
ret = pkt.size;
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
return ret;
}
*got_packet_ptr = 0;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
- av_free_packet(avpkt);
+ av_packet_unref(avpkt);
av_init_packet(avpkt);
return 0;
}
}
if (ret < 0 || !*got_packet_ptr) {
- av_free_packet(avpkt);
+ av_packet_unref(avpkt);
av_init_packet(avpkt);
goto end;
}
*got_packet_ptr = 0;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
- av_free_packet(avpkt);
+ av_packet_unref(avpkt);
av_init_packet(avpkt);
avpkt->size = 0;
return 0;
}
if (ret < 0 || !*got_packet_ptr)
- av_free_packet(avpkt);
+ av_packet_unref(avpkt);
emms_c();
return ret;
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR 7
+#define LIBAVCODEC_VERSION_MINOR 8
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
#ifndef FF_API_AVPICTURE
#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
+#ifndef FF_API_AVPACKET_OLD_API
+#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
#endif /* AVCODEC_VERSION_H */
while ((res = snd_pcm_readi(s->h, pkt->data, pkt->size / s->frame_size)) < 0) {
if (res == -EAGAIN) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EAGAIN);
}
if (ff_alsa_xrun_recover(s1, res) < 0) {
av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n",
snd_strerror(res));
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
AVPacket pkt;
while (av_fifo_size(fifo)) {
av_fifo_generic_read(fifo, &pkt, sizeof(pkt), NULL);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
}
av_fifo_free(fifo);
}
ret = read(s->fd, pkt->data, pkt->size);
if (ret <= 0){
- av_free_packet(pkt);
+ av_packet_unref(pkt);
pkt->size = 0;
if (ret<0) return AVERROR(errno);
else return AVERROR_EOF;
if ((pa_simple_read(pd->s, pkt->data, pkt->size, &res)) < 0) {
av_log(s, AV_LOG_ERROR, "pa_simple_read failed: %s\n",
pa_strerror(res));
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
ret = sio_read(s->hdl, pkt->data, pkt->size);
if (ret == 0 || sio_eof(s->hdl)) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR_EOF;
}
if (res < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return res;
}
avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
pktl = ctx->pktl;
while (pktl) {
AVPacketList *next = pktl->next;
- av_free_packet(&pktl->pkt);
+ av_packet_unref(&pktl->pkt);
av_free(pktl);
pktl = next;
}
movie->frame->sample_aspect_ratio.num,
movie->frame->sample_aspect_ratio.den);
// We got it. Free the packet since we are returning
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
return 0;
}
}
// Free the packet that was allocated by av_read_frame
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
}
// On multi-frame source we should stop the mixing process when
ret = avio_read(s->pb, &pkt->data[8], size);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
} else
packet_read = 1;
break;
ret = av_get_packet(s->pb, pkt, size);
if (ret != size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO);
}
if (AV_RB16(pkt->data) & 0x8000) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR_EOF;
}
pkt->size = size;
read = avio_read(s->pb, pkt->data + 1, size - 1);
if (read != size - 1) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
fail:
av_freep(&desc);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
return ret;
}
asf_pkt->flags = 0;
asf_pkt->dts = 0;
asf_pkt->duration = 0;
- av_free_packet(&asf_pkt->avpkt);
+ av_packet_unref(&asf_pkt->avpkt);
av_init_packet(&asf_pkt->avpkt);
}
if (p > asf_pkt->avpkt.data + asf_pkt->data_size)
break;
}
- av_free_packet(&asf_pkt->avpkt);
+ av_packet_unref(&asf_pkt->avpkt);
asf_pkt->avpkt = pkt;
return 0;
for (i = 0; i < ASF_MAX_STREAMS; i++) {
av_dict_free(&asf->asf_sd[i].asf_met);
if (i < asf->nb_streams) {
- av_free_packet(&asf->asf_st[i]->pkt.avpkt);
+ av_packet_unref(&asf->asf_st[i]->pkt.avpkt);
av_freep(&asf->asf_st[i]);
}
}
pkt->flags = 0;
pkt->dts = 0;
pkt->duration = 0;
- av_free_packet(&pkt->avpkt);
+ av_packet_unref(&pkt->avpkt);
av_init_packet(&pkt->avpkt);
}
}
}
if (st_found)
break;
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
}
*pos = pkt_pos;
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
return dts;
}
* until the next av_read_frame() call or closing the file. If the caller
* requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy
* of it.
- * In both cases, the packet must be freed with av_free_packet() when it is no
+ * In both cases, the packet must be freed with av_packet_unref() when it is no
* longer needed.
*
* @section lavf_decoding_seek Seeking
* If pkt->buf is NULL, then the packet is valid until the next
* av_read_frame() or until avformat_close_input(). Otherwise the packet
* is valid indefinitely. In both cases the packet must be freed with
- * av_free_packet when it is no longer needed. For video, the packet contains
+ * av_packet_unref when it is no longer needed. For video, the packet contains
* exactly one frame. For audio, it contains an integer number of frames if each
* frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames
* have a variable size (e.g. MPEG audio), then it contains one frame.
pkt->buf = avbuf;
pkt->flags |= AV_PKT_FLAG_KEY;
if (size < 0)
- av_free_packet(pkt);
+ av_packet_unref(pkt);
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
!st->codec->codec_tag && read_gab2_sub(st, pkt)) {
ast->frame_offset++;
{
AVIStream *ast2 = st2->priv_data;
int64_t ts2 = av_rescale_q(timestamp, st->time_base, st2->time_base);
- av_free_packet(&ast2->sub_pkt);
+ av_packet_unref(&ast2->sub_pkt);
if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 ||
avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0)
ff_read_packet(ast2->sub_ctx, &ast2->sub_pkt);
avformat_close_input(&ast->sub_ctx);
}
av_free(ast->sub_buffer);
- av_free_packet(&ast->sub_pkt);
+ av_packet_unref(&ast->sub_pkt);
}
}
pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
if (ret < size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
return 0;
fail:
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);
if (ret < 1 || (pkt->data[0] & CDG_MASK) == CDG_COMMAND)
break;
- av_free_packet(pkt);
+ av_packet_unref(pkt);
}
if (!priv->got_first_packet) {
memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);
ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret);
if (!first) {
ret = av_append_packet(pb, pkt, 12);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
} else
}
ret = av_append_packet(pb, pkt, frame_size);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
}
ret = avio_read(pb, &pkt->data[4], pkt_size);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
if (ret < pkt_size)
return pkt->size;
error_eof:
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF;
}
ret = avio_read(s->pb, pkt->data + offset,
size2 - offset);
if (ret < size2 - offset) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF;
}
ret = avio_read(s->pb, pkt->data + offset, size - offset);
if (ret < size - offset) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF;
}
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
if(ret != size){
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
if(pal_size) memcpy(pkt->data, pal, pal_size);
case AV_CODEC_ID_ADPCM_EA_R3:
if (pkt->size < 4) {
av_log(s, AV_LOG_ERROR, "Packet is too short\n");
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR_INVALIDDATA;
}
if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3)
ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
size - FLIC_PREAMBLE_SIZE);
if (ret != size - FLIC_PREAMBLE_SIZE) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
ret = AVERROR(EIO);
}
packet_read = 1;
ret = avio_read(pb, pkt->data, size);
if (ret != size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
ret = AVERROR(EIO);
}
ret = avio_read(s->pb, pkt->data + 1, size - 1);
if (ret < size - 1) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF;
}
ret = av_get_packet(s->pb, pkt, size);
if (ret < GSM_BLOCK_SIZE) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO);
}
pkt->size = ret;
for (i = 0; i < c->n_variants; i++) {
struct variant *var = c->variants[i];
free_segment_list(var);
- av_free_packet(&var->pkt);
+ av_packet_unref(&var->pkt);
av_free(var->pb.buffer);
if (var->input)
ffurl_close(var->input);
c->seek_timestamp = AV_NOPTS_VALUE;
break;
}
- av_free_packet(&var->pkt);
+ av_packet_unref(&var->pkt);
reset_packet(&var->pkt);
}
}
ffurl_close(var->input);
var->input = NULL;
}
- av_free_packet(&var->pkt);
+ av_packet_unref(&var->pkt);
reset_packet(&var->pkt);
var->pb.eof_reached = 0;
/* Clear any buffered data */
Hnm4DemuxContext *hnm = s->priv_data;
if (hnm->vpkt.size > 0)
- av_free_packet(&hnm->vpkt);
+ av_packet_unref(&hnm->vpkt);
return 0;
}
return ret;
else if (ret != chunk_size) {
av_log(s, AV_LOG_ERROR, "incomplete packet\n");
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
if (command == 1) {
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
AVPALETTE_SIZE);
if (!pal) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
memcpy(pal, palette, AVPALETTE_SIZE);
pkt->pos = avio_tell(s->pb);
pkt->duration = enc->block_align == 38 ? 160 : 240;
if ((ret = avio_read(s->pb, pkt->data, enc->block_align)) != enc->block_align) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO);
}
}
if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO); /* signal EOF */
} else {
s->img_count++;
pkt->stream_index = 0;
ret = avio_read(s->pb, pkt->data, size);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
pkt->size = ret;
* Interleave a packet per dts in an output media file.
*
* Packets with pkt->destruct == av_destruct_packet will be freed inside this
- * function, so they cannot be used after it. Note that calling av_free_packet()
+ * function, so they cannot be used after it. Note that calling av_packet_unref()
* on them is still safe.
*
* @param s media file handle
if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
s->decode_map_chunk_size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return CHUNK_EOF;
}
if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
s->video_chunk_size) != s->video_chunk_size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return CHUNK_EOF;
}
ret = av_append_packet(s->pb, pkt, size);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "failed to grow packet\n");
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
}
return ret2;
if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret2 < 0 ? ret2 : AVERROR_EOF;
}
memcpy(out->data + old_size, in->data, in->size);
- av_free_packet(in);
+ av_packet_unref(in);
av_free(in);
return 0;
}
if (matroska->packets) {
int n;
for (n = 0; n < matroska->num_packets; n++) {
- av_free_packet(matroska->packets[n]);
+ av_packet_unref(matroska->packets[n]);
av_free(matroska->packets[n]);
}
av_freep(&matroska->packets);
// check if we have an audio packet cached
if (mkv->cur_audio_pkt.size > 0) {
ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);
- av_free_packet(&mkv->cur_audio_pkt);
+ av_packet_unref(&mkv->cur_audio_pkt);
if (ret < 0) {
av_log(s, AV_LOG_ERROR,
"Could not write cached audio packet ret:%d\n", ret);
// check if we have an audio packet cached
if (mkv->cur_audio_pkt.size > 0) {
ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);
- av_free_packet(&mkv->cur_audio_pkt);
+ av_packet_unref(&mkv->cur_audio_pkt);
if (ret < 0) {
av_log(s, AV_LOG_ERROR,
"Could not write cached audio packet ret:%d\n", ret);
ret = avio_read(s->pb, pkt->data, pkt->size);
if (ret < 0)
- av_free_packet(pkt);
+ av_packet_unref(pkt);
mmf->data_size -= ret;
while ((pktl = mp3->queue)) {
if (write && (ret = mp3_write_audio_packet(s, &pktl->pkt)) < 0)
write = 0;
- av_free_packet(&pktl->pkt);
+ av_packet_unref(&pktl->pkt);
mp3->queue = pktl->next;
av_freep(&pktl);
}
if(c->curbits)
avio_seek(s->pb, -4, SEEK_CUR);
if(ret < size){
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO);
}
pkt->size = ret + 4;
c->curframe = lastframe;
return ret;
}
- av_free_packet(pkt);
+ av_packet_unref(pkt);
}
return 0;
}
ret = read_packet(s, pkt->data, ts->raw_packet_size, &data);
pkt->pos = avio_tell(s->pb);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
if (data != pkt->data)
if (s->oformat->interleave_packet) {
int ret = s->oformat->interleave_packet(s, out, in, flush);
if (in)
- av_free_packet(in);
+ av_packet_unref(in);
return ret;
} else
return ff_interleave_packet_per_dts(s, out, in, flush);
if (ret >= 0)
s->streams[opkt.stream_index]->nb_frames++;
- av_free_packet(&opkt);
+ av_packet_unref(&opkt);
if (ret < 0)
return ret;
if (ret >= 0)
s->streams[pkt.stream_index]->nb_frames++;
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
if (ret < 0)
goto fail;
if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)
s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
- av_free_packet(&pktl->pkt);
+ av_packet_unref(&pktl->pkt);
av_freep(&pktl);
pktl = next;
}
ret = av_get_packet(s->pb, pkt, size);
if (ret != size) {
- if (ret > 0) av_free_packet(pkt);
+ if (ret > 0) av_packet_unref(pkt);
return AVERROR(EIO);
}
av_freep(&nsv->nsvs_file_offset);
av_freep(&nsv->nsvs_timestamps);
if (nsv->ahead[0].data)
- av_free_packet(&nsv->ahead[0]);
+ av_packet_unref(&nsv->ahead[0]);
if (nsv->ahead[1].data)
- av_free_packet(&nsv->ahead[1]);
+ av_packet_unref(&nsv->ahead[1]);
return 0;
}
memcpy(pkt->data, hdr, copyhdrsize);
ret = avio_read(pb, pkt->data + copyhdrsize, size);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
if (ret < size)
if(pkt->size != sector_count*VIDEO_DATA_CHUNK_SIZE){
if(pkt->data)
av_log(s, AV_LOG_ERROR, "missmatching sector_count\n");
- av_free_packet(pkt);
+ av_packet_unref(pkt);
if (av_new_packet(pkt, sector_count*VIDEO_DATA_CHUNK_SIZE))
return AVERROR(EIO);
int i;
for(i=0; i<32; i++){
if(str->channels[i].tmp_pkt.data)
- av_free_packet(&str->channels[i].tmp_pkt);
+ av_packet_unref(&str->channels[i].tmp_pkt);
}
return 0;
pkt->stream_index = 0;
ret = ffio_read_partial(s->pb, pkt->data, size);
if (ret < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
} else if (ret < size) {
/* initialize end of packet for partial reads to avoid reading
/** fill the packet */
ret = av_get_packet(pb, pkt, sample->size);
if(ret != sample->size){
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
void ff_rm_free_rmstream (RMStream *rms)
{
- av_free_packet(&rms->pkt);
+ av_packet_unref(&rms->pkt);
}
static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){
vst->slices = ((hdr & 0x3F) << 1) + 1;
vst->videobufsize = len2 + 8*vst->slices + 1;
- av_free_packet(&vst->pkt); //FIXME this should be output.
+ av_packet_unref(&vst->pkt); //FIXME this should be output.
if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)
return AVERROR(ENOMEM);
vst->videobufpos = 8*vst->slices + 1;
if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))
|| st->discard >= AVDISCARD_ALL){
- av_free_packet(pkt);
+ av_packet_unref(pkt);
} else
break;
}
ret = av_get_packet(pb, pkt, frame_size);
if (ret != frame_size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
pkt->duration = 1;
} else {
ret = av_get_packet(pb, pkt, index_entry->size);
if (ret != index_entry->size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
return 1; // FIXME: return 0 if last packet
}
}
- av_free_packet(pkt);
+ av_packet_unref(pkt);
}
return res == 1 ? -1 : res;
data->split_pos = 0;
if (!data->split_buf) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
memcpy(data->split_buf, buf, data->split_buf_size);
av_freep(&qt->pkt.data);
qt->pkt.data = av_realloc(NULL, qt->remaining * qt->bytes_per_frame);
if (!qt->pkt.data) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
qt->pkt.size = qt->remaining * qt->bytes_per_frame;
data->split_buf = av_malloc(data->split_buf_size);
if (!data->split_buf) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
}
int i = s->nb_streams;
AVStream *st = avformat_new_stream(s, NULL);
if (!st) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
st->id = i;
ts_str(dts_buf, pkt.dts, st->time_base);
ts_str(ts_buf, pkt.pts, st->time_base);
printf("ret:%-10s st:%2d flags:%d dts:%s pts:%s pos:%7" PRId64 " size:%6d", ret_str(ret), pkt.stream_index, pkt.flags, dts_buf, ts_buf, pkt.pos, pkt.size);
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
} else
printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace
printf("\n");
frame->frame_size);
if (ret != frame->frame_size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
ret = AVERROR(EIO);
}
pkt->stream_index = frame->stream_index;
pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE;
if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR_EOF;
}
ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);
ret = spdif_get_offset_and_codec(s, data_type, pkt->data,
&offset, &codec_id);
if (ret) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
/* first packet, create a stream */
AVStream *st = avformat_new_stream(s, NULL);
if (!st) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ret = av_get_packet(pb, pkt, size);
if (ret != size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
} else {
ret = av_get_packet(pb, pkt, thp->audiosize);
if (ret != thp->audiosize) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
pkt->pos = orig_pos;
if (!pkt->size)
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return pkt->size > orig_size ? pkt->size - orig_size : ret;
}
av_log(s, AV_LOG_WARNING,
"Dropped corrupted packet (stream = %d)\n",
pkt->stream_index);
- av_free_packet(pkt);
+ av_packet_unref(pkt);
continue;
}
while (*pkt_buf) {
AVPacketList *pktl = *pkt_buf;
*pkt_buf = pktl->next;
- av_free_packet(&pktl->pkt);
+ av_packet_unref(&pktl->pkt);
av_freep(&pktl);
}
*pkt_buf_end = NULL;
goto fail;
if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) {
- av_free_packet(&out_pkt);
+ av_packet_unref(&out_pkt);
ret = AVERROR(ENOMEM);
goto fail;
}
}
fail:
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
return ret;
} else {
/* free packet */
- av_free_packet(&cur_pkt);
+ av_packet_unref(&cur_pkt);
}
}
} while (read_status == AVERROR(EAGAIN));
if (read_status < 0)
break;
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
if (stream_index == pkt.stream_index)
if ((pkt.flags & AV_PKT_FLAG_KEY) && pkt.dts > timestamp)
break;
st->duration = duration;
}
}
- av_free_packet(pkt);
+ av_packet_unref(pkt);
}
} while (end_time == AV_NOPTS_VALUE &&
filesize > (DURATION_MAX_READ_SIZE << retry) &&
av_parser_close(st->parser);
}
if (st->attached_pic.data)
- av_free_packet(&st->attached_pic);
+ av_packet_unref(&st->attached_pic);
av_dict_free(&st->metadata);
av_freep(&st->probe_data.buf);
av_free(st->index_entries);
ret = avio_read(s->pb, pkt->data+2, size);
if (ret<=0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
Wc3DemuxContext *wc3 = s->priv_data;
if (wc3->vpkt.size > 0)
- av_free_packet(&wc3->vpkt);
+ av_packet_unref(&wc3->vpkt);
return 0;
}
return AVERROR(EIO);
ret = avio_read(pb, pkt->data, chunk_size);
if (ret != chunk_size) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);
ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);
if (ret != wc->header.blocksize) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO);
}
while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {
if ((ret = wv_read_block_header(s, s->pb)) < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
off = pkt->size;
if ((ret = av_grow_packet(pkt, WV_HEADER_SIZE + wc->header.blocksize)) < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return ret;
}
memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE);
ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize);
if (ret != wc->header.blocksize) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return (ret < 0) ? ret : AVERROR_EOF;
}
}
return ret;
}
pts = pkt->pts;
- av_free_packet(pkt);
+ av_packet_unref(pkt);
} while(pts < timestamp);
return 0;
}
return yop->audio_block_length;
err_out:
- av_free_packet(&yop->video_packet);
+ av_packet_unref(&yop->video_packet);
return ret;
}
static int yop_read_close(AVFormatContext *s)
{
YopDecContext *yop = s->priv_data;
- av_free_packet(&yop->video_packet);
+ av_packet_unref(&yop->video_packet);
return 0;
}
if (avio_seek(s->pb, frame_pos, SEEK_SET) < 0)
return -1;
- av_free_packet(&yop->video_packet);
+ av_packet_unref(&yop->video_packet);
yop->odd_frame = timestamp & 1;
return 0;
}
close(fd);
}
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
pktnum++;
if (maxpkts && (pktnum >= maxpkts))
break;