Up until now, we had a PacketList structure which is actually a PacketListEntry; a proper PacketList did not exist and all the related functions just passed pointers to pointers to the head and tail elements around. All these pointers were actually consecutive elements of their containing structs, i.e. the users already treated them as if they were a struct. So add a proper PacketList struct and rename the current PacketList to PacketListEntry; also make the functions use this structure instead of the pair of pointers.
Unified · Split
| @@ -535,13 +535,12 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb) · 534 unmodified lines | |||
| 535 | pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb); | 535 | pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb); |
| 536 | } | 536 | } |
| 537 | 537 | ||
| 538 | int avpriv_packet_list_put(PacketList **packet_buffer, | 538 | int avpriv_packet_list_put(PacketList *packet_buffer, |
| 539 | PacketList **plast_pktl, | ||
| 540 | AVPacket *pkt, | 539 | AVPacket *pkt, |
| 541 | int (*copy)(AVPacket *dst, const AVPacket *src), | 540 | int (*copy)(AVPacket *dst, const AVPacket *src), |
| 542 | int flags) | 541 | int flags) |
| 543 | { | 542 | { |
| 544 | PacketList *pktl = av_malloc(sizeof(PacketList)); | 543 | PacketListEntry *pktl = av_malloc(sizeof(*pktl)); |
| 545 | int ret; | 544 | int ret; |
| 546 | 545 | ||
| 547 | if (!pktl) | 546 | if (!pktl) |
| @@ -565,44 +564,41 @@ int avpriv_packet_list_put(PacketList **packet_buffer, · 17 unmodified lines | |||
| 565 | 564 | ||
| 566 | pktl->next = NULL; | 565 | pktl->next = NULL; |
| 567 | 566 | ||
| 568 | if (*packet_buffer) | 567 | if (packet_buffer->head) |
| 569 | (*plast_pktl)->next = pktl; | 568 | packet_buffer->tail->next = pktl; |
| 570 | else | 569 | else |
| 571 | *packet_buffer = pktl; | 570 | packet_buffer->head = pktl; |
| 572 | 571 | ||
| 573 | /* Add the packet in the buffered packet list. */ | 572 | /* Add the packet in the buffered packet list. */ |
| 574 | *plast_pktl = pktl; | 573 | packet_buffer->tail = pktl; |
| 575 | return 0; | 574 | return 0; |
| 576 | } | 575 | } |
| 577 | 576 | ||
| 578 | int avpriv_packet_list_get(PacketList **pkt_buffer, | 577 | int avpriv_packet_list_get(PacketList *pkt_buffer, |
| 579 | PacketList **pkt_buffer_end, | ||
| 580 | AVPacket *pkt) | 578 | AVPacket *pkt) |
| 581 | { | 579 | { |
| 582 | PacketList *pktl; | 580 | PacketListEntry *pktl = pkt_buffer->head; |
| 583 | if (!*pkt_buffer) | 581 | if (!pktl) |
| 584 | return AVERROR(EAGAIN); | 582 | return AVERROR(EAGAIN); |
| 585 | pktl = *pkt_buffer; | ||
| 586 | *pkt = pktl->pkt; | 583 | *pkt = pktl->pkt; |
| 587 | *pkt_buffer = pktl->next; | 584 | pkt_buffer->head = pktl->next; |
| 588 | if (!pktl->next) | 585 | if (!pkt_buffer->head) |
| 589 | *pkt_buffer_end = NULL; | 586 | pkt_buffer->tail = NULL; |
| 590 | av_freep(&pktl); | 587 | av_freep(&pktl); |
| 591 | return 0; | 588 | return 0; |
| 592 | } | 589 | } |
| 593 | 590 | ||
| 594 | void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end) | 591 | void avpriv_packet_list_free(PacketList *pkt_buf) |
| 595 | { | 592 | { |
| 596 | PacketList *tmp = *pkt_buf; | 593 | PacketListEntry *tmp = pkt_buf->head; |
| 597 | 594 | ||
| 598 | while (tmp) { | 595 | while (tmp) { |
| 599 | PacketList *pktl = tmp; | 596 | PacketListEntry *pktl = tmp; |
| 600 | tmp = pktl->next; | 597 | tmp = pktl->next; |
| 601 | av_packet_unref(&pktl->pkt); | 598 | av_packet_unref(&pktl->pkt); |
| 602 | av_freep(&pktl); | 599 | av_freep(&pktl); |
| 603 | } | 600 | } |
| 604 | *pkt_buf = NULL; | 601 | pkt_buf->head = pkt_buf->tail = NULL; |
| 605 | *pkt_buf_end = NULL; | ||
| 606 | } | 602 | } |
| 607 | 603 | ||
| 608 | int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type) | 604 | int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type) |
| @@ -23,16 +23,19 @@ · 22 unmodified lines | |||
| 23 | 23 | ||
| 24 | #include "packet.h" | 24 | #include "packet.h" |
| 25 | 25 | ||
| 26 | typedef struct PacketList { | 26 | typedef struct PacketListEntry { |
| 27 | struct PacketList *next; | 27 | struct PacketListEntry *next; |
| 28 | AVPacket pkt; | 28 | AVPacket pkt; |
| 29 | } PacketListEntry; | ||
| 30 | |||
| 31 | typedef struct PacketList { | ||
| 32 | PacketListEntry *head, *tail; | ||
| 29 | } PacketList; | 33 | } PacketList; |
| 30 | 34 | ||
| 31 | /** | 35 | /** |
| 32 | * Append an AVPacket to the list. | 36 | * Append an AVPacket to the list. |
| 33 | * | 37 | * |
| 34 | * @param head List head element | 38 | * @param list A PacketList |
| 35 | * @param tail List tail element | ||
| 36 | * @param pkt The packet being appended. The data described in it will | 39 | * @param pkt The packet being appended. The data described in it will |
| 37 | * be made reference counted if it isn't already. | 40 | * be made reference counted if it isn't already. |
| 38 | * @param copy A callback to copy the contents of the packet to the list. | 41 | * @param copy A callback to copy the contents of the packet to the list. |
| @@ -41,8 +44,7 @@ typedef struct PacketList { · 2 unmodified lines | |||
| 41 | * @return 0 on success, negative AVERROR value on failure. On failure, | 44 | * @return 0 on success, negative AVERROR value on failure. On failure, |
| 42 | the packet and the list are unchanged. | 45 | the packet and the list are unchanged. |
| 43 | */ | 46 | */ |
| 44 | int avpriv_packet_list_put(PacketList **head, PacketList **tail, | 47 | int avpriv_packet_list_put(PacketList *list, AVPacket *pkt, |
| 45 | AVPacket *pkt, | ||
| 46 | int (*copy)(AVPacket *dst, const AVPacket *src), | 48 | int (*copy)(AVPacket *dst, const AVPacket *src), |
| 47 | int flags); | 49 | int flags); |
| 48 | 50 | ||
| @@ -52,22 +54,17 @@ int avpriv_packet_list_put(PacketList **head, PacketList **tail, · 3 unmodified lines | |||
| 52 | * @note The pkt will be overwritten completely on success. The caller | 54 | * @note The pkt will be overwritten completely on success. The caller |
| 53 | * owns the packet and must unref it by itself. | 55 | * owns the packet and must unref it by itself. |
| 54 | * | 56 | * |
| 55 | * @param head List head element | 57 | * @param head A pointer to a PacketList struct |
| 56 | * @param tail List tail element | ||
| 57 | * @param pkt Pointer to an AVPacket struct | 58 | * @param pkt Pointer to an AVPacket struct |
| 58 | * @return 0 on success, and a packet is returned. AVERROR(EAGAIN) if | 59 | * @return 0 on success, and a packet is returned. AVERROR(EAGAIN) if |
| 59 | * the list was empty. | 60 | * the list was empty. |
| 60 | */ | 61 | */ |
| 61 | int avpriv_packet_list_get(PacketList **head, PacketList **tail, | 62 | int avpriv_packet_list_get(PacketList *list, AVPacket *pkt); |
| 62 | AVPacket *pkt); | ||
| 63 | 63 | ||
| 64 | /** | 64 | /** |
| 65 | * Wipe the list and unref all the packets in it. | 65 | * Wipe the list and unref all the packets in it. |
| 66 | * | ||
| 67 | * @param head List head element | ||
| 68 | * @param tail List tail element | ||
| 69 | */ | 66 | */ |
| 70 | void avpriv_packet_list_free(PacketList **head, PacketList **tail); | 67 | void avpriv_packet_list_free(PacketList *list); |
| 71 | 68 | ||
| 72 | int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type); | 69 | int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type); |
| 73 | 70 | ||
| @@ -29,6 +29,9 @@ · 28 unmodified lines | |||
| 29 | #define IDeckLinkProfileAttributes IDeckLinkAttributes | 29 | #define IDeckLinkProfileAttributes IDeckLinkAttributes |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | extern "C" { | ||
| 33 | #include "libavcodec/packet_internal.h" | ||
| 34 | } | ||
| 32 | #include "libavutil/thread.h" | 35 | #include "libavutil/thread.h" |
| 33 | #include "decklink_common_c.h" | 36 | #include "decklink_common_c.h" |
| 34 | #if CONFIG_LIBKLVANC | 37 | #if CONFIG_LIBKLVANC |
| @@ -75,7 +78,7 @@ class decklink_output_callback; · 40 unmodified lines | |||
| 75 | class decklink_input_callback; | 78 | class decklink_input_callback; |
| 76 | 79 | ||
| 77 | typedef struct AVPacketQueue { | 80 | typedef struct AVPacketQueue { |
| 78 | PacketList *first_pkt, *last_pkt; | 81 | PacketList pkt_list; |
| 79 | int nb_packets; | 82 | int nb_packets; |
| 80 | unsigned long long size; | 83 | unsigned long long size; |
| 81 | int abort_request; | 84 | int abort_request; |
| @@ -483,16 +483,16 @@ static void avpacket_queue_init(AVFormatContext *avctx, AVPacketQueue *q) · 482 unmodified lines | |||
| 483 | 483 | ||
| 484 | static void avpacket_queue_flush(AVPacketQueue *q) | 484 | static void avpacket_queue_flush(AVPacketQueue *q) |
| 485 | { | 485 | { |
| 486 | PacketList *pkt, *pkt1; | 486 | PacketListEntry *pkt, *pkt1; |
| 487 | 487 | ||
| 488 | pthread_mutex_lock(&q->mutex); | 488 | pthread_mutex_lock(&q->mutex); |
| 489 | for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) { | 489 | for (pkt = q->pkt_list.head; pkt != NULL; pkt = pkt1) { |
| 490 | pkt1 = pkt->next; | 490 | pkt1 = pkt->next; |
| 491 | av_packet_unref(&pkt->pkt); | 491 | av_packet_unref(&pkt->pkt); |
| 492 | av_freep(&pkt); | 492 | av_freep(&pkt); |
| 493 | } | 493 | } |
| 494 | q->last_pkt = NULL; | 494 | q->pkt_list.head = NULL; |
| 495 | q->first_pkt = NULL; | 495 | q->pkt_list.tail = NULL; |
| 496 | q->nb_packets = 0; | 496 | q->nb_packets = 0; |
| 497 | q->size = 0; | 497 | q->size = 0; |
| 498 | pthread_mutex_unlock(&q->mutex); | 498 | pthread_mutex_unlock(&q->mutex); |
| @@ -516,7 +516,7 @@ static unsigned long long avpacket_queue_size(AVPacketQueue *q) · 17 unmodified lines | |||
| 516 | 516 | ||
| 517 | static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) | 517 | static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) |
| 518 | { | 518 | { |
| 519 | PacketList *pkt1; | 519 | PacketListEntry *pkt1; |
| 520 | 520 | ||
| 521 | // Drop Packet if queue size is > maximum queue size | 521 | // Drop Packet if queue size is > maximum queue size |
| 522 | if (avpacket_queue_size(q) > (uint64_t)q->max_q_size) { | 522 | if (avpacket_queue_size(q) > (uint64_t)q->max_q_size) { |
| @@ -530,7 +530,7 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) · 7 unmodified lines | |||
| 530 | return -1; | 530 | return -1; |
| 531 | } | 531 | } |
| 532 | 532 | ||
| 533 | pkt1 = (PacketList *)av_malloc(sizeof(PacketList)); | 533 | pkt1 = (PacketListEntry *)av_malloc(sizeof(*pkt1)); |
| 534 | if (!pkt1) { | 534 | if (!pkt1) { |
| 535 | av_packet_unref(pkt); | 535 | av_packet_unref(pkt); |
| 536 | return -1; | 536 | return -1; |
| @@ -540,13 +540,13 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) · 3 unmodified lines | |||
| 540 | 540 | ||
| 541 | pthread_mutex_lock(&q->mutex); | 541 | pthread_mutex_lock(&q->mutex); |
| 542 | 542 | ||
| 543 | if (!q->last_pkt) { | 543 | if (!q->pkt_list.tail) { |
| 544 | q->first_pkt = pkt1; | 544 | q->pkt_list.head = pkt1; |
| 545 | } else { | 545 | } else { |
| 546 | q->last_pkt->next = pkt1; | 546 | q->pkt_list.tail->next = pkt1; |
| 547 | } | 547 | } |
| 548 | 548 | ||
| 549 | q->last_pkt = pkt1; | 549 | q->pkt_list.tail = pkt1; |
| 550 | q->nb_packets++; | 550 | q->nb_packets++; |
| 551 | q->size += pkt1->pkt.size + sizeof(*pkt1); | 551 | q->size += pkt1->pkt.size + sizeof(*pkt1); |
| 552 | 552 | ||
| @@ -558,17 +558,16 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) · 5 unmodified lines | |||
| 558 | 558 | ||
| 559 | static int avpacket_queue_get(AVPacketQueue *q, AVPacket *pkt, int block) | 559 | static int avpacket_queue_get(AVPacketQueue *q, AVPacket *pkt, int block) |
| 560 | { | 560 | { |
| 561 | PacketList *pkt1; | ||
| 562 | int ret; | 561 | int ret; |
| 563 | 562 | ||
| 564 | pthread_mutex_lock(&q->mutex); | 563 | pthread_mutex_lock(&q->mutex); |
| 565 | 564 | ||
| 566 | for (;; ) { | 565 | for (;; ) { |
| 567 | pkt1 = q->first_pkt; | 566 | PacketListEntry *pkt1 = q->pkt_list.head; |
| 568 | if (pkt1) { | 567 | if (pkt1) { |
| 569 | q->first_pkt = pkt1->next; | 568 | q->pkt_list.head = pkt1->next; |
| 570 | if (!q->first_pkt) { | 569 | if (!q->pkt_list.head) { |
| 571 | q->last_pkt = NULL; | 570 | q->pkt_list.tail = NULL; |
| 572 | } | 571 | } |
| 573 | q->nb_packets--; | 572 | q->nb_packets--; |
| 574 | q->size -= pkt1->pkt.size + sizeof(*pkt1); | 573 | q->size -= pkt1->pkt.size + sizeof(*pkt1); |
| @@ -238,7 +238,7 @@ static int · 237 unmodified lines | |||
| 238 | dshow_read_close(AVFormatContext *s) | 238 | dshow_read_close(AVFormatContext *s) |
| 239 | { | 239 | { |
| 240 | struct dshow_ctx *ctx = s->priv_data; | 240 | struct dshow_ctx *ctx = s->priv_data; |
| 241 | PacketList *pktl; | 241 | PacketListEntry *pktl; |
| 242 | 242 | ||
| 243 | if (ctx->control) { | 243 | if (ctx->control) { |
| 244 | IMediaControl_Stop(ctx->control); | 244 | IMediaControl_Stop(ctx->control); |
| @@ -298,7 +298,7 @@ dshow_read_close(AVFormatContext *s) · 53 unmodified lines | |||
| 298 | 298 | ||
| 299 | pktl = ctx->pktl; | 299 | pktl = ctx->pktl; |
| 300 | while (pktl) { | 300 | while (pktl) { |
| 301 | PacketList *next = pktl->next; | 301 | PacketListEntry *next = pktl->next; |
| 302 | av_packet_unref(&pktl->pkt); | 302 | av_packet_unref(&pktl->pkt); |
| 303 | av_free(pktl); | 303 | av_free(pktl); |
| 304 | pktl = next; | 304 | pktl = next; |
| @@ -342,7 +342,7 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, e · 37 unmodified lines | |||
| 342 | { | 342 | { |
| 343 | AVFormatContext *s = priv_data; | 343 | AVFormatContext *s = priv_data; |
| 344 | struct dshow_ctx *ctx = s->priv_data; | 344 | struct dshow_ctx *ctx = s->priv_data; |
| 345 | PacketList **ppktl, *pktl_next; | 345 | PacketListEntry **ppktl, *pktl_next; |
| 346 | 346 | ||
| 347 | // dump_videohdr(s, vdhdr); | 347 | // dump_videohdr(s, vdhdr); |
| 348 | 348 | ||
| @@ -351,7 +351,7 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, e · 2 unmodified lines | |||
| 351 | if(shall_we_drop(s, index, devtype)) | 351 | if(shall_we_drop(s, index, devtype)) |
| 352 | goto fail; | 352 | goto fail; |
| 353 | 353 | ||
| 354 | pktl_next = av_mallocz(sizeof(PacketList)); | 354 | pktl_next = av_mallocz(sizeof(*pktl_next)); |
| 355 | if(!pktl_next) | 355 | if(!pktl_next) |
| 356 | goto fail; | 356 | goto fail; |
| 357 | 357 | ||
| @@ -1868,7 +1868,7 @@ static int dshow_check_event_queue(IMediaEvent *media_event) · 1510 unmodified lines | |||
| 1868 | static int dshow_read_packet(AVFormatContext *s, AVPacket *pkt) | 1868 | static int dshow_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 1869 | { | 1869 | { |
| 1870 | struct dshow_ctx *ctx = s->priv_data; | 1870 | struct dshow_ctx *ctx = s->priv_data; |
| 1871 | PacketList *pktl = NULL; | 1871 | PacketListEntry *pktl = NULL; |
| 1872 | 1872 | ||
| 1873 | while (!ctx->eof && !pktl) { | 1873 | while (!ctx->eof && !pktl) { |
| 1874 | WaitForSingleObject(ctx->mutex, INFINITE); | 1874 | WaitForSingleObject(ctx->mutex, INFINITE); |
| @@ -322,7 +322,7 @@ struct dshow_ctx { · 321 unmodified lines | |||
| 322 | HANDLE mutex; | 322 | HANDLE mutex; |
| 323 | HANDLE event[2]; /* event[0] is set by DirectShow | 323 | HANDLE event[2]; /* event[0] is set by DirectShow |
| 324 | * event[1] is set by callback() */ | 324 | * event[1] is set by callback() */ |
| 325 | PacketList *pktl; | 325 | PacketListEntry *pktl; |
| 326 | 326 | ||
| 327 | int eof; | 327 | int eof; |
| 328 | 328 | ||
| @@ -45,7 +45,7 @@ struct vfw_ctx { · 44 unmodified lines | |||
| 45 | HWND hwnd; | 45 | HWND hwnd; |
| 46 | HANDLE mutex; | 46 | HANDLE mutex; |
| 47 | HANDLE event; | 47 | HANDLE event; |
| 48 | PacketList *pktl; | 48 | PacketListEntry *pktl; |
| 49 | unsigned int curbufsize; | 49 | unsigned int curbufsize; |
| 50 | unsigned int frame_num; | 50 | unsigned int frame_num; |
| 51 | char *video_size; /**< A string describing video size, set by a private option. */ | 51 | char *video_size; /**< A string describing video size, set by a private option. */ |
| @@ -179,7 +179,7 @@ static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr) · 127 unmodified lines | |||
| 179 | { | 179 | { |
| 180 | AVFormatContext *s; | 180 | AVFormatContext *s; |
| 181 | struct vfw_ctx *ctx; | 181 | struct vfw_ctx *ctx; |
| 182 | PacketList **ppktl, *pktl_next; | 182 | PacketListEntry **ppktl, *pktl_next; |
| 183 | 183 | ||
| 184 | s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | 184 | s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA); |
| 185 | ctx = s->priv_data; | 185 | ctx = s->priv_data; |
| @@ -191,7 +191,7 @@ static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr) · 5 unmodified lines | |||
| 191 | 191 | ||
| 192 | WaitForSingleObject(ctx->mutex, INFINITE); | 192 | WaitForSingleObject(ctx->mutex, INFINITE); |
| 193 | 193 | ||
| 194 | pktl_next = av_mallocz(sizeof(PacketList)); | 194 | pktl_next = av_mallocz(sizeof(*pktl_next)); |
| 195 | if(!pktl_next) | 195 | if(!pktl_next) |
| 196 | goto fail; | 196 | goto fail; |
| 197 | 197 | ||
| @@ -220,7 +220,7 @@ fail: · 22 unmodified lines | |||
| 220 | static int vfw_read_close(AVFormatContext *s) | 220 | static int vfw_read_close(AVFormatContext *s) |
| 221 | { | 221 | { |
| 222 | struct vfw_ctx *ctx = s->priv_data; | 222 | struct vfw_ctx *ctx = s->priv_data; |
| 223 | PacketList *pktl; | 223 | PacketListEntry *pktl; |
| 224 | 224 | ||
| 225 | if(ctx->hwnd) { | 225 | if(ctx->hwnd) { |
| 226 | SendMessage(ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0); | 226 | SendMessage(ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0); |
| @@ -234,7 +234,7 @@ static int vfw_read_close(AVFormatContext *s) · 7 unmodified lines | |||
| 234 | 234 | ||
| 235 | pktl = ctx->pktl; | 235 | pktl = ctx->pktl; |
| 236 | while (pktl) { | 236 | while (pktl) { |
| 237 | PacketList *next = pktl->next; | 237 | PacketListEntry *next = pktl->next; |
| 238 | av_packet_unref(&pktl->pkt); | 238 | av_packet_unref(&pktl->pkt); |
| 239 | av_free(pktl); | 239 | av_free(pktl); |
| 240 | pktl = next; | 240 | pktl = next; |
| @@ -440,7 +440,7 @@ fail: · 199 unmodified lines | |||
| 440 | static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt) | 440 | static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 441 | { | 441 | { |
| 442 | struct vfw_ctx *ctx = s->priv_data; | 442 | struct vfw_ctx *ctx = s->priv_data; |
| 443 | PacketList *pktl = NULL; | 443 | PacketListEntry *pktl = NULL; |
| 444 | 444 | ||
| 445 | while(!pktl) { | 445 | while(!pktl) { |
| 446 | WaitForSingleObject(ctx->mutex, INFINITE); | 446 | WaitForSingleObject(ctx->mutex, INFINITE); |
| @@ -37,7 +37,7 @@ typedef struct AIFFOutputContext { · 36 unmodified lines | |||
| 37 | int64_t frames; | 37 | int64_t frames; |
| 38 | int64_t ssnd; | 38 | int64_t ssnd; |
| 39 | int audio_stream_idx; | 39 | int audio_stream_idx; |
| 40 | PacketList *pict_list, *pict_list_end; | 40 | PacketList pict_list; |
| 41 | int write_id3v2; | 41 | int write_id3v2; |
| 42 | int id3v2_version; | 42 | int id3v2_version; |
| 43 | } AIFFOutputContext; | 43 | } AIFFOutputContext; |
| @@ -48,9 +48,9 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff) · 4 unmodified lines | |||
| 48 | uint64_t pos, end, size; | 48 | uint64_t pos, end, size; |
| 49 | ID3v2EncContext id3v2 = { 0 }; | 49 | ID3v2EncContext id3v2 = { 0 }; |
| 50 | AVIOContext *pb = s->pb; | 50 | AVIOContext *pb = s->pb; |
| 51 | PacketList *pict_list = aiff->pict_list; | 51 | PacketListEntry *list_entry = aiff->pict_list.head; |
| 52 | 52 | ||
| 53 | if (!s->metadata && !s->nb_chapters && !aiff->pict_list) | 53 | if (!s->metadata && !s->nb_chapters && !list_entry) |
| 54 | return 0; | 54 | return 0; |
| 55 | 55 | ||
| 56 | avio_wl32(pb, MKTAG('I', 'D', '3', ' ')); | 56 | avio_wl32(pb, MKTAG('I', 'D', '3', ' ')); |
| @@ -59,10 +59,10 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff) · 2 unmodified lines | |||
| 59 | 59 | ||
| 60 | ff_id3v2_start(&id3v2, pb, aiff->id3v2_version, ID3v2_DEFAULT_MAGIC); | 60 | ff_id3v2_start(&id3v2, pb, aiff->id3v2_version, ID3v2_DEFAULT_MAGIC); |
| 61 | ff_id3v2_write_metadata(s, &id3v2); | 61 | ff_id3v2_write_metadata(s, &id3v2); |
| 62 | while (pict_list) { | 62 | while (list_entry) { |
| 63 | if ((ret = ff_id3v2_write_apic(s, &id3v2, &pict_list->pkt)) < 0) | 63 | if ((ret = ff_id3v2_write_apic(s, &id3v2, &list_entry->pkt)) < 0) |
| 64 | return ret; | 64 | return ret; |
| 65 | pict_list = pict_list->next; | 65 | list_entry = list_entry->next; |
| 66 | } | 66 | } |
| 67 | ff_id3v2_finish(&id3v2, pb, s->metadata_header_padding); | 67 | ff_id3v2_finish(&id3v2, pb, s->metadata_header_padding); |
| 68 | 68 | ||
| @@ -218,8 +218,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) · 149 unmodified lines | |||
| 218 | if (s->streams[pkt->stream_index]->nb_frames >= 1) | 218 | if (s->streams[pkt->stream_index]->nb_frames >= 1) |
| 219 | return 0; | 219 | return 0; |
| 220 | 220 | ||
| 221 | return avpriv_packet_list_put(&aiff->pict_list, &aiff->pict_list_end, | 221 | return avpriv_packet_list_put(&aiff->pict_list, pkt, NULL, 0); |
| 222 | pkt, NULL, 0); | ||
| 223 | } | 222 | } |
| 224 | 223 | ||
| 225 | return 0; | 224 | return 0; |
| @@ -265,7 +264,7 @@ static void aiff_deinit(AVFormatContext *s) · 39 unmodified lines | |||
| 265 | { | 264 | { |
| 266 | AIFFOutputContext *aiff = s->priv_data; | 265 | AIFFOutputContext *aiff = s->priv_data; |
| 267 | 266 | ||
| 268 | avpriv_packet_list_free(&aiff->pict_list, &aiff->pict_list_end); | 267 | avpriv_packet_list_free(&aiff->pict_list); |
| 269 | } | 268 | } |
| 270 | 269 | ||
| 271 | #define OFFSET(x) offsetof(AIFFOutputContext, x) | 270 | #define OFFSET(x) offsetof(AIFFOutputContext, x) |
| @@ -537,7 +537,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 536 unmodified lines | |||
| 537 | #endif | 537 | #endif |
| 538 | 538 | ||
| 539 | for (;;) { | 539 | for (;;) { |
| 540 | PacketList *pktl = si->raw_packet_buffer; | 540 | PacketListEntry *pktl = si->raw_packet_buffer.head; |
| 541 | AVStream *st; | 541 | AVStream *st; |
| 542 | FFStream *sti; | 542 | FFStream *sti; |
| 543 | const AVPacket *pkt1; | 543 | const AVPacket *pkt1; |
| @@ -548,8 +548,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 4 unmodified lines | |||
| 548 | if ((err = probe_codec(s, st, NULL)) < 0) | 548 | if ((err = probe_codec(s, st, NULL)) < 0) |
| 549 | return err; | 549 | return err; |
| 550 | if (ffstream(st)->request_probe <= 0) { | 550 | if (ffstream(st)->request_probe <= 0) { |
| 551 | avpriv_packet_list_get(&si->raw_packet_buffer, | 551 | avpriv_packet_list_get(&si->raw_packet_buffer, pkt); |
| 552 | &si->raw_packet_buffer_end, pkt); | ||
| 553 | si->raw_packet_buffer_size -= pkt->size; | 552 | si->raw_packet_buffer_size -= pkt->size; |
| 554 | return 0; | 553 | return 0; |
| 555 | } | 554 | } |
| @@ -624,13 +623,12 @@ FF_ENABLE_DEPRECATION_WARNINGS · 68 unmodified lines | |||
| 624 | return 0; | 623 | return 0; |
| 625 | 624 | ||
| 626 | err = avpriv_packet_list_put(&si->raw_packet_buffer, | 625 | err = avpriv_packet_list_put(&si->raw_packet_buffer, |
| 627 | &si->raw_packet_buffer_end, | ||
| 628 | pkt, NULL, 0); | 626 | pkt, NULL, 0); |
| 629 | if (err < 0) { | 627 | if (err < 0) { |
| 630 | av_packet_unref(pkt); | 628 | av_packet_unref(pkt); |
| 631 | return err; | 629 | return err; |
| 632 | } | 630 | } |
| 633 | pkt1 = &si->raw_packet_buffer_end->pkt; | 631 | pkt1 = &si->raw_packet_buffer.tail->pkt; |
| 634 | si->raw_packet_buffer_size += pkt1->size; | 632 | si->raw_packet_buffer_size += pkt1->size; |
| 635 | 633 | ||
| 636 | if ((err = probe_codec(s, st, pkt1)) < 0) | 634 | if ((err = probe_codec(s, st, pkt1)) < 0) |
| @@ -716,13 +714,14 @@ static int has_decode_delay_been_guessed(AVStream *st) · 79 unmodified lines | |||
| 716 | return sti->nb_decoded_frames >= 20; | 714 | return sti->nb_decoded_frames >= 20; |
| 717 | } | 715 | } |
| 718 | 716 | ||
| 719 | static PacketList *get_next_pkt(AVFormatContext *s, AVStream *st, PacketList *pktl) | 717 | static PacketListEntry *get_next_pkt(AVFormatContext *s, AVStream *st, |
| 718 | PacketListEntry *pktl) | ||
| 720 | { | 719 | { |
| 721 | FFFormatContext *const si = ffformatcontext(s); | 720 | FFFormatContext *const si = ffformatcontext(s); |
| 722 | if (pktl->next) | 721 | if (pktl->next) |
| 723 | return pktl->next; | 722 | return pktl->next; |
| 724 | if (pktl == si->packet_buffer_end) | 723 | if (pktl == si->packet_buffer.tail) |
| 725 | return si->parse_queue; | 724 | return si->parse_queue.head; |
| 726 | return NULL; | 725 | return NULL; |
| 727 | } | 726 | } |
| 728 | 727 | ||
| @@ -774,7 +773,7 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t · 45 unmodified lines | |||
| 774 | * of the packets in a window. | 773 | * of the packets in a window. |
| 775 | */ | 774 | */ |
| 776 | static void update_dts_from_pts(AVFormatContext *s, int stream_index, | 775 | static void update_dts_from_pts(AVFormatContext *s, int stream_index, |
| 777 | PacketList *pkt_buffer) | 776 | PacketListEntry *pkt_buffer) |
| 778 | { | 777 | { |
| 779 | AVStream *const st = s->streams[stream_index]; | 778 | AVStream *const st = s->streams[stream_index]; |
| 780 | int delay = ffstream(st)->avctx->has_b_frames; | 779 | int delay = ffstream(st)->avctx->has_b_frames; |
| @@ -804,7 +803,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, · 23 unmodified lines | |||
| 804 | FFFormatContext *const si = ffformatcontext(s); | 803 | FFFormatContext *const si = ffformatcontext(s); |
| 805 | AVStream *const st = s->streams[stream_index]; | 804 | AVStream *const st = s->streams[stream_index]; |
| 806 | FFStream *const sti = ffstream(st); | 805 | FFStream *const sti = ffstream(st); |
| 807 | PacketList *pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue; | 806 | PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head; |
| 808 | 807 | ||
| 809 | uint64_t shift; | 808 | uint64_t shift; |
| 810 | 809 | ||
| @@ -823,7 +822,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, · 12 unmodified lines | |||
| 823 | if (is_relative(pts)) | 822 | if (is_relative(pts)) |
| 824 | pts += shift; | 823 | pts += shift; |
| 825 | 824 | ||
| 826 | for (PacketList *pktl_it = pktl; pktl_it; pktl_it = get_next_pkt(s, st, pktl_it)) { | 825 | for (PacketListEntry *pktl_it = pktl; pktl_it; pktl_it = get_next_pkt(s, st, pktl_it)) { |
| 827 | if (pktl_it->pkt.stream_index != stream_index) | 826 | if (pktl_it->pkt.stream_index != stream_index) |
| 828 | continue; | 827 | continue; |
| 829 | if (is_relative(pktl_it->pkt.pts)) | 828 | if (is_relative(pktl_it->pkt.pts)) |
| @@ -856,7 +855,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, · 26 unmodified lines | |||
| 856 | { | 855 | { |
| 857 | FFFormatContext *const si = ffformatcontext(s); | 856 | FFFormatContext *const si = ffformatcontext(s); |
| 858 | FFStream *const sti = ffstream(st); | 857 | FFStream *const sti = ffstream(st); |
| 859 | PacketList *pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue; | 858 | PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head; |
| 860 | int64_t cur_dts = RELATIVE_TS_BASE; | 859 | int64_t cur_dts = RELATIVE_TS_BASE; |
| 861 | 860 | ||
| 862 | if (sti->first_dts != AV_NOPTS_VALUE) { | 861 | if (sti->first_dts != AV_NOPTS_VALUE) { |
| @@ -882,7 +881,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, · 19 unmodified lines | |||
| 882 | av_log(s, AV_LOG_DEBUG, "first_dts %s but no packet with dts in the queue\n", av_ts2str(sti->first_dts)); | 881 | av_log(s, AV_LOG_DEBUG, "first_dts %s but no packet with dts in the queue\n", av_ts2str(sti->first_dts)); |
| 883 | return; | 882 | return; |
| 884 | } | 883 | } |
| 885 | pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue; | 884 | pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head; |
| 886 | sti->first_dts = cur_dts; | 885 | sti->first_dts = cur_dts; |
| 887 | } else if (sti->cur_dts != RELATIVE_TS_BASE) | 886 | } else if (sti->cur_dts != RELATIVE_TS_BASE) |
| 888 | return; | 887 | return; |
| @@ -998,7 +997,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, · 109 unmodified lines | |||
| 998 | } | 997 | } |
| 999 | } | 998 | } |
| 1000 | 999 | ||
| 1001 | if (pkt->duration > 0 && (si->packet_buffer || si->parse_queue)) | 1000 | if (pkt->duration > 0 && (si->packet_buffer.head || si->parse_queue.head)) |
| 1002 | update_initial_durations(s, st, pkt->stream_index, pkt->duration); | 1001 | update_initial_durations(s, st, pkt->stream_index, pkt->duration); |
| 1003 | 1002 | ||
| 1004 | /* Correct timestamps with byte offset if demuxers only have timestamps | 1003 | /* Correct timestamps with byte offset if demuxers only have timestamps |
| @@ -1195,7 +1194,6 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, · 190 unmodified lines | |||
| 1195 | compute_pkt_fields(s, st, sti->parser, out_pkt, next_dts, next_pts); | 1194 | compute_pkt_fields(s, st, sti->parser, out_pkt, next_dts, next_pts); |
| 1196 | 1195 | ||
| 1197 | ret = avpriv_packet_list_put(&si->parse_queue, | 1196 | ret = avpriv_packet_list_put(&si->parse_queue, |
| 1198 | &si->parse_queue_end, | ||
| 1199 | out_pkt, NULL, 0); | 1197 | out_pkt, NULL, 0); |
| 1200 | if (ret < 0) | 1198 | if (ret < 0) |
| 1201 | goto fail; | 1199 | goto fail; |
| @@ -1225,7 +1223,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 23 unmodified lines | |||
| 1225 | int ret, got_packet = 0; | 1223 | int ret, got_packet = 0; |
| 1226 | AVDictionary *metadata = NULL; | 1224 | AVDictionary *metadata = NULL; |
| 1227 | 1225 | ||
| 1228 | while (!got_packet && !si->parse_queue) { | 1226 | while (!got_packet && !si->parse_queue.head) { |
| 1229 | AVStream *st; | 1227 | AVStream *st; |
| 1230 | FFStream *sti; | 1228 | FFStream *sti; |
| 1231 | 1229 | ||
| @@ -1338,8 +1336,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 106 unmodified lines | |||
| 1338 | } | 1336 | } |
| 1339 | } | 1337 | } |
| 1340 | 1338 | ||
| 1341 | if (!got_packet && si->parse_queue) | 1339 | if (!got_packet && si->parse_queue.head) |
| 1342 | ret = avpriv_packet_list_get(&si->parse_queue, &si->parse_queue_end, pkt); | 1340 | ret = avpriv_packet_list_get(&si->parse_queue, pkt); |
| 1343 | 1341 | ||
| 1344 | if (ret >= 0) { | 1342 | if (ret >= 0) { |
| 1345 | AVStream *const st = s->streams[pkt->stream_index]; | 1343 | AVStream *const st = s->streams[pkt->stream_index]; |
| @@ -1420,9 +1418,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 74 unmodified lines | |||
| 1420 | AVStream *st; | 1418 | AVStream *st; |
| 1421 | 1419 | ||
| 1422 | if (!genpts) { | 1420 | if (!genpts) { |
| 1423 | ret = si->packet_buffer | 1421 | ret = si->packet_buffer.head |
| 1424 | ? avpriv_packet_list_get(&si->packet_buffer, | 1422 | ? avpriv_packet_list_get(&si->packet_buffer, pkt) |
| 1425 | &si->packet_buffer_end, pkt) | ||
| 1426 | : read_frame_internal(s, pkt); | 1423 | : read_frame_internal(s, pkt); |
| 1427 | if (ret < 0) | 1424 | if (ret < 0) |
| 1428 | return ret; | 1425 | return ret; |
| @@ -1430,7 +1427,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 1 unmodified line | |||
| 1430 | } | 1427 | } |
| 1431 | 1428 | ||
| 1432 | for (;;) { | 1429 | for (;;) { |
| 1433 | PacketList *pktl = si->packet_buffer; | 1430 | PacketListEntry *pktl = si->packet_buffer.head; |
| 1434 | 1431 | ||
| 1435 | if (pktl) { | 1432 | if (pktl) { |
| 1436 | AVPacket *next_pkt = &pktl->pkt; | 1433 | AVPacket *next_pkt = &pktl->pkt; |
| @@ -1463,15 +1460,14 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 26 unmodified lines | |||
| 1463 | // 3. the packets for this stream at the end of the files had valid dts. | 1460 | // 3. the packets for this stream at the end of the files had valid dts. |
| 1464 | next_pkt->pts = last_dts + next_pkt->duration; | 1461 | next_pkt->pts = last_dts + next_pkt->duration; |
| 1465 | } | 1462 | } |
| 1466 | pktl = si->packet_buffer; | 1463 | pktl = si->packet_buffer.head; |
| 1467 | } | 1464 | } |
| 1468 | 1465 | ||
| 1469 | /* read packet from packet buffer, if there is data */ | 1466 | /* read packet from packet buffer, if there is data */ |
| 1470 | st = s->streams[next_pkt->stream_index]; | 1467 | st = s->streams[next_pkt->stream_index]; |
| 1471 | if (!(next_pkt->pts == AV_NOPTS_VALUE && st->discard < AVDISCARD_ALL && | 1468 | if (!(next_pkt->pts == AV_NOPTS_VALUE && st->discard < AVDISCARD_ALL && |
| 1472 | next_pkt->dts != AV_NOPTS_VALUE && !eof)) { | 1469 | next_pkt->dts != AV_NOPTS_VALUE && !eof)) { |
| 1473 | ret = avpriv_packet_list_get(&si->packet_buffer, | 1470 | ret = avpriv_packet_list_get(&si->packet_buffer, pkt); |
| 1474 | &si->packet_buffer_end, pkt); | ||
| 1475 | goto return_packet; | 1471 | goto return_packet; |
| 1476 | } | 1472 | } |
| 1477 | } | 1473 | } |
| @@ -1486,7 +1482,6 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 8 unmodified lines | |||
| 1486 | } | 1482 | } |
| 1487 | 1483 | ||
| 1488 | ret = avpriv_packet_list_put(&si->packet_buffer, | 1484 | ret = avpriv_packet_list_put(&si->packet_buffer, |
| 1489 | &si->packet_buffer_end, | ||
| 1490 | pkt, NULL, 0); | 1485 | pkt, NULL, 0); |
| 1491 | if (ret < 0) { | 1486 | if (ret < 0) { |
| 1492 | av_packet_unref(pkt); | 1487 | av_packet_unref(pkt); |
| @@ -2598,12 +2593,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 1105 unmodified lines | |||
| 2598 | 2593 | ||
| 2599 | if (!(ic->flags & AVFMT_FLAG_NOBUFFER)) { | 2594 | if (!(ic->flags & AVFMT_FLAG_NOBUFFER)) { |
| 2600 | ret = avpriv_packet_list_put(&si->packet_buffer, | 2595 | ret = avpriv_packet_list_put(&si->packet_buffer, |
| 2601 | &si->packet_buffer_end, | ||
| 2602 | pkt1, NULL, 0); | 2596 | pkt1, NULL, 0); |
| 2603 | if (ret < 0) | 2597 | if (ret < 0) |
| 2604 | goto unref_then_goto_end; | 2598 | goto unref_then_goto_end; |
| 2605 | 2599 | ||
| 2606 | pkt = &si->packet_buffer_end->pkt; | 2600 | pkt = &si->packet_buffer.tail->pkt; |
| 2607 | } else { | 2601 | } else { |
| 2608 | pkt = pkt1; | 2602 | pkt = pkt1; |
| 2609 | } | 2603 | } |
| @@ -2751,8 +2745,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 141 unmodified lines | |||
| 2751 | 2745 | ||
| 2752 | // EOF already reached while reading the stream above. | 2746 | // EOF already reached while reading the stream above. |
| 2753 | // So continue with reoordering DTS with whatever delay we have. | 2747 | // So continue with reoordering DTS with whatever delay we have. |
| 2754 | if (si->packet_buffer && !has_decode_delay_been_guessed(st)) { | 2748 | if (si->packet_buffer.head && !has_decode_delay_been_guessed(st)) { |
| 2755 | update_dts_from_pts(ic, stream_index, si->packet_buffer); | 2749 | update_dts_from_pts(ic, stream_index, si->packet_buffer.head); |
| 2756 | } | 2750 | } |
| 2757 | } | 2751 | } |
| 2758 | } | 2752 | } |
| @@ -40,7 +40,7 @@ typedef struct FlacMuxerContext { · 39 unmodified lines | |||
| 40 | int audio_stream_idx; | 40 | int audio_stream_idx; |
| 41 | int waiting_pics; | 41 | int waiting_pics; |
| 42 | /* audio packets are queued here until we get all the attached pictures */ | 42 | /* audio packets are queued here until we get all the attached pictures */ |
| 43 | PacketList *queue, *queue_end; | 43 | PacketList queue; |
| 44 | 44 | ||
| 45 | /* updated streaminfo sent by the encoder at the end */ | 45 | /* updated streaminfo sent by the encoder at the end */ |
| 46 | uint8_t streaminfo[FLAC_STREAMINFO_SIZE]; | 46 | uint8_t streaminfo[FLAC_STREAMINFO_SIZE]; |
| @@ -306,8 +306,8 @@ static int flac_queue_flush(AVFormatContext *s) · 259 unmodified lines | |||
| 306 | if (ret < 0) | 306 | if (ret < 0) |
| 307 | write = 0; | 307 | write = 0; |
| 308 | 308 | ||
| 309 | while (c->queue) { | 309 | while (c->queue.head) { |
| 310 | avpriv_packet_list_get(&c->queue, &c->queue_end, pkt); | 310 | avpriv_packet_list_get(&c->queue, pkt); |
| 311 | if (write && (ret = flac_write_audio_packet(s, pkt)) < 0) | 311 | if (write && (ret = flac_write_audio_packet(s, pkt)) < 0) |
| 312 | write = 0; | 312 | write = 0; |
| 313 | av_packet_unref(pkt); | 313 | av_packet_unref(pkt); |
| @@ -347,7 +347,7 @@ static void flac_deinit(struct AVFormatContext *s) · 33 unmodified lines | |||
| 347 | { | 347 | { |
| 348 | FlacMuxerContext *c = s->priv_data; | 348 | FlacMuxerContext *c = s->priv_data; |
| 349 | 349 | ||
| 350 | avpriv_packet_list_free(&c->queue, &c->queue_end); | 350 | avpriv_packet_list_free(&c->queue); |
| 351 | for (unsigned i = 0; i < s->nb_streams; i++) | 351 | for (unsigned i = 0; i < s->nb_streams; i++) |
| 352 | av_packet_free((AVPacket **)&s->streams[i]->priv_data); | 352 | av_packet_free((AVPacket **)&s->streams[i]->priv_data); |
| 353 | } | 353 | } |
| @@ -360,7 +360,7 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt) · 6 unmodified lines | |||
| 360 | if (pkt->stream_index == c->audio_stream_idx) { | 360 | if (pkt->stream_index == c->audio_stream_idx) { |
| 361 | if (c->waiting_pics) { | 361 | if (c->waiting_pics) { |
| 362 | /* buffer audio packets until we get all the pictures */ | 362 | /* buffer audio packets until we get all the pictures */ |
| 363 | ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, NULL, 0); | 363 | ret = avpriv_packet_list_put(&c->queue, pkt, NULL, 0); |
| 364 | if (ret < 0) { | 364 | if (ret < 0) { |
| 365 | av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n"); | 365 | av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n"); |
| 366 | c->waiting_pics = 0; | 366 | c->waiting_pics = 0; |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | |||
| 25 | 25 | ||
| 26 | #include "libavcodec/avcodec.h" | 26 | #include "libavcodec/avcodec.h" |
| 27 | #include "libavcodec/bsf.h" | 27 | #include "libavcodec/bsf.h" |
| 28 | #include "libavcodec/packet_internal.h" | ||
| 28 | 29 | ||
| 29 | #include "avformat.h" | 30 | #include "avformat.h" |
| 30 | #include "os_support.h" | 31 | #include "os_support.h" |
| @@ -92,8 +93,7 @@ typedef struct FFFormatContext { · 61 unmodified lines | |||
| 92 | * not decoded, for example to get the codec parameters in MPEG | 93 | * not decoded, for example to get the codec parameters in MPEG |
| 93 | * streams. | 94 | * streams. |
| 94 | */ | 95 | */ |
| 95 | struct PacketList *packet_buffer; | 96 | PacketList packet_buffer; |
| 96 | struct PacketList *packet_buffer_end; | ||
| 97 | 97 | ||
| 98 | /* av_seek_frame() support */ | 98 | /* av_seek_frame() support */ |
| 99 | int64_t data_offset; /**< offset of the first packet */ | 99 | int64_t data_offset; /**< offset of the first packet */ |
| @@ -104,13 +104,11 @@ typedef struct FFFormatContext { · 4 unmodified lines | |||
| 104 | * be identified, as parsing cannot be done without knowing the | 104 | * be identified, as parsing cannot be done without knowing the |
| 105 | * codec. | 105 | * codec. |
| 106 | */ | 106 | */ |
| 107 | struct PacketList *raw_packet_buffer; | 107 | PacketList raw_packet_buffer; |
| 108 | struct PacketList *raw_packet_buffer_end; | ||
| 109 | /** | 108 | /** |
| 110 | * Packets split by the parser get queued here. | 109 | * Packets split by the parser get queued here. |
| 111 | */ | 110 | */ |
| 112 | struct PacketList *parse_queue; | 111 | PacketList parse_queue; |
| 113 | struct PacketList *parse_queue_end; | ||
| 114 | /** | 112 | /** |
| 115 | * The generic code uses this as a temporary packet | 113 | * The generic code uses this as a temporary packet |
| 116 | * to parse packets or for muxing, especially flushing. | 114 | * to parse packets or for muxing, especially flushing. |
| @@ -393,7 +391,7 @@ typedef struct FFStream { · 276 unmodified lines | |||
| 393 | /** | 391 | /** |
| 394 | * last packet in packet_buffer for this stream when muxing. | 392 | * last packet in packet_buffer for this stream when muxing. |
| 395 | */ | 393 | */ |
| 396 | struct PacketList *last_in_packet_buffer; | 394 | PacketListEntry *last_in_packet_buffer; |
| 397 | 395 | ||
| 398 | int64_t last_IP_pts; | 396 | int64_t last_IP_pts; |
| 399 | int last_IP_duration; | 397 | int last_IP_duration; |
| @@ -396,8 +396,7 @@ typedef struct MatroskaDemuxContext { · 395 unmodified lines | |||
| 396 | AVPacket *pkt; | 396 | AVPacket *pkt; |
| 397 | 397 | ||
| 398 | /* the packet queue */ | 398 | /* the packet queue */ |
| 399 | PacketList *queue; | 399 | PacketList queue; |
| 400 | PacketList *queue_end; | ||
| 401 | 400 | ||
| 402 | int done; | 401 | int done; |
| 403 | 402 | ||
| @@ -3112,11 +3111,11 @@ static int matroska_read_header(AVFormatContext *s) · 2708 unmodified lines | |||
| 3112 | static int matroska_deliver_packet(MatroskaDemuxContext *matroska, | 3111 | static int matroska_deliver_packet(MatroskaDemuxContext *matroska, |
| 3113 | AVPacket *pkt) | 3112 | AVPacket *pkt) |
| 3114 | { | 3113 | { |
| 3115 | if (matroska->queue) { | 3114 | if (matroska->queue.head) { |
| 3116 | MatroskaTrack *tracks = matroska->tracks.elem; | 3115 | MatroskaTrack *tracks = matroska->tracks.elem; |
| 3117 | MatroskaTrack *track; | 3116 | MatroskaTrack *track; |
| 3118 | 3117 | ||
| 3119 | avpriv_packet_list_get(&matroska->queue, &matroska->queue_end, pkt); | 3118 | avpriv_packet_list_get(&matroska->queue, pkt); |
| 3120 | track = &tracks[pkt->stream_index]; | 3119 | track = &tracks[pkt->stream_index]; |
| 3121 | if (track->has_palette) { | 3120 | if (track->has_palette) { |
| 3122 | uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); | 3121 | uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); |
| @@ -3138,7 +3137,7 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska, · 15 unmodified lines | |||
| 3138 | */ | 3137 | */ |
| 3139 | static void matroska_clear_queue(MatroskaDemuxContext *matroska) | 3138 | static void matroska_clear_queue(MatroskaDemuxContext *matroska) |
| 3140 | { | 3139 | { |
| 3141 | avpriv_packet_list_free(&matroska->queue, &matroska->queue_end); | 3140 | avpriv_packet_list_free(&matroska->queue); |
| 3142 | } | 3141 | } |
| 3143 | 3142 | ||
| 3144 | static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, | 3143 | static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, |
| @@ -3304,7 +3303,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska, · 159 unmodified lines | |||
| 3304 | track->audio.buf_timecode = AV_NOPTS_VALUE; | 3303 | track->audio.buf_timecode = AV_NOPTS_VALUE; |
| 3305 | pkt->pos = pos; | 3304 | pkt->pos = pos; |
| 3306 | pkt->stream_index = st->index; | 3305 | pkt->stream_index = st->index; |
| 3307 | ret = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0); | 3306 | ret = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0); |
| 3308 | if (ret < 0) { | 3307 | if (ret < 0) { |
| 3309 | av_packet_unref(pkt); | 3308 | av_packet_unref(pkt); |
| 3310 | return AVERROR(ENOMEM); | 3309 | return AVERROR(ENOMEM); |
| @@ -3526,7 +3525,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, · 215 unmodified lines | |||
| 3526 | pkt->duration = duration; | 3525 | pkt->duration = duration; |
| 3527 | pkt->pos = pos; | 3526 | pkt->pos = pos; |
| 3528 | 3527 | ||
| 3529 | err = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0); | 3528 | err = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0); |
| 3530 | if (err < 0) { | 3529 | if (err < 0) { |
| 3531 | av_packet_unref(pkt); | 3530 | av_packet_unref(pkt); |
| 3532 | return AVERROR(ENOMEM); | 3531 | return AVERROR(ENOMEM); |
| @@ -3628,7 +3627,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, · 95 unmodified lines | |||
| 3628 | pkt->pos = pos; | 3627 | pkt->pos = pos; |
| 3629 | pkt->duration = lace_duration; | 3628 | pkt->duration = lace_duration; |
| 3630 | 3629 | ||
| 3631 | res = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0); | 3630 | res = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0); |
| 3632 | if (res < 0) { | 3631 | if (res < 0) { |
| 3633 | av_packet_unref(pkt); | 3632 | av_packet_unref(pkt); |
| 3634 | return AVERROR(ENOMEM); | 3633 | return AVERROR(ENOMEM); |
| @@ -4030,10 +4029,10 @@ static int webm_clusters_start_with_keyframe(AVFormatContext *s) · 395 unmodified lines | |||
| 4030 | matroska_reset_status(matroska, 0, cluster_pos); | 4029 | matroska_reset_status(matroska, 0, cluster_pos); |
| 4031 | matroska_clear_queue(matroska); | 4030 | matroska_clear_queue(matroska); |
| 4032 | if (matroska_parse_cluster(matroska) < 0 || | 4031 | if (matroska_parse_cluster(matroska) < 0 || |
| 4033 | !matroska->queue) { | 4032 | !matroska->queue.head) { |
| 4034 | break; | 4033 | break; |
| 4035 | } | 4034 | } |
| 4036 | pkt = &matroska->queue->pkt; | 4035 | pkt = &matroska->queue.head->pkt; |
| 4037 | // 4 + read is the length of the cluster id and the cluster length field. | 4036 | // 4 + read is the length of the cluster id and the cluster length field. |
| 4038 | cluster_pos += 4 + read + cluster_length; | 4037 | cluster_pos += 4 + read + cluster_length; |
| 4039 | if (!(pkt->flags & AV_PKT_FLAG_KEY)) { | 4038 | if (!(pkt->flags & AV_PKT_FLAG_KEY)) { |
| @@ -5339,7 +5339,7 @@ static int mov_write_squashed_packet(AVFormatContext *s, MOVTrack *track) · 5338 unmodified lines | |||
| 5339 | 5339 | ||
| 5340 | switch (track->st->codecpar->codec_id) { | 5340 | switch (track->st->codecpar->codec_id) { |
| 5341 | case AV_CODEC_ID_TTML: { | 5341 | case AV_CODEC_ID_TTML: { |
| 5342 | int had_packets = !!track->squashed_packet_queue; | 5342 | int had_packets = !!track->squashed_packet_queue.head; |
| 5343 | 5343 | ||
| 5344 | if ((ret = ff_mov_generate_squashed_ttml_packet(s, track, squashed_packet)) < 0) { | 5344 | if ((ret = ff_mov_generate_squashed_ttml_packet(s, track, squashed_packet)) < 0) { |
| 5345 | goto finish_squash; | 5345 | goto finish_squash; |
| @@ -6190,7 +6190,6 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) · 844 unmodified lines | |||
| 6190 | /* The following will reset pkt and is only allowed to be used | 6190 | /* The following will reset pkt and is only allowed to be used |
| 6191 | * because we return immediately. afterwards. */ | 6191 | * because we return immediately. afterwards. */ |
| 6192 | if ((ret = avpriv_packet_list_put(&trk->squashed_packet_queue, | 6192 | if ((ret = avpriv_packet_list_put(&trk->squashed_packet_queue, |
| 6193 | &trk->squashed_packet_queue_end, | ||
| 6194 | pkt, NULL, 0)) < 0) { | 6193 | pkt, NULL, 0)) < 0) { |
| 6195 | return ret; | 6194 | return ret; |
| 6196 | } | 6195 | } |
| @@ -6478,8 +6477,7 @@ static void mov_free(AVFormatContext *s) · 281 unmodified lines | |||
| 6478 | ff_mov_cenc_free(&track->cenc); | 6477 | ff_mov_cenc_free(&track->cenc); |
| 6479 | ffio_free_dyn_buf(&track->mdat_buf); | 6478 | ffio_free_dyn_buf(&track->mdat_buf); |
| 6480 | 6479 | ||
| 6481 | avpriv_packet_list_free(&track->squashed_packet_queue, | 6480 | avpriv_packet_list_free(&track->squashed_packet_queue); |
| 6482 | &track->squashed_packet_queue_end); | ||
| 6483 | } | 6481 | } |
| 6484 | 6482 | ||
| 6485 | av_freep(&mov->tracks); | 6483 | av_freep(&mov->tracks); |
| @@ -167,7 +167,7 @@ typedef struct MOVTrack { · 166 unmodified lines | |||
| 167 | 167 | ||
| 168 | unsigned int squash_fragment_samples_to_one; //< flag to note formats where all samples for a fragment are to be squashed | 168 | unsigned int squash_fragment_samples_to_one; //< flag to note formats where all samples for a fragment are to be squashed |
| 169 | 169 | ||
| 170 | PacketList *squashed_packet_queue, *squashed_packet_queue_end; | 170 | PacketList squashed_packet_queue; |
| 171 | } MOVTrack; | 171 | } MOVTrack; |
| 172 | 172 | ||
| 173 | typedef enum { | 173 | typedef enum { |
| @@ -70,9 +70,7 @@ static int mov_write_ttml_document_from_queue(AVFormatContext *s, · 69 unmodified lines | |||
| 70 | return ret; | 70 | return ret; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | while (!avpriv_packet_list_get(&track->squashed_packet_queue, | 73 | while (!avpriv_packet_list_get(&track->squashed_packet_queue, pkt)) { |
| 74 | &track->squashed_packet_queue_end, | ||
| 75 | pkt)) { | ||
| 76 | end_ts = FFMAX(end_ts, pkt->pts + pkt->duration); | 74 | end_ts = FFMAX(end_ts, pkt->pts + pkt->duration); |
| 77 | 75 | ||
| 78 | // in case of the 'dfxp' muxing mode, each written document is offset | 76 | // in case of the 'dfxp' muxing mode, each written document is offset |
| @@ -121,7 +119,7 @@ int ff_mov_generate_squashed_ttml_packet(AVFormatContext *s, · 42 unmodified lines | |||
| 121 | goto cleanup; | 119 | goto cleanup; |
| 122 | } | 120 | } |
| 123 | 121 | ||
| 124 | if (!track->squashed_packet_queue) { | 122 | if (!track->squashed_packet_queue.head) { |
| 125 | // empty queue, write minimal empty document with zero duration | 123 | // empty queue, write minimal empty document with zero duration |
| 126 | avio_write(ttml_ctx->pb, empty_ttml_document, | 124 | avio_write(ttml_ctx->pb, empty_ttml_document, |
| 127 | sizeof(empty_ttml_document) - 1); | 125 | sizeof(empty_ttml_document) - 1); |
| @@ -132,7 +132,7 @@ typedef struct MP3Context { · 131 unmodified lines | |||
| 132 | int pics_to_write; | 132 | int pics_to_write; |
| 133 | 133 | ||
| 134 | /* audio packets are queued here until we get all the attached pictures */ | 134 | /* audio packets are queued here until we get all the attached pictures */ |
| 135 | PacketList *queue, *queue_end; | 135 | PacketList queue; |
| 136 | } MP3Context; | 136 | } MP3Context; |
| 137 | 137 | ||
| 138 | static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}}; | 138 | static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}}; |
| @@ -387,8 +387,8 @@ static int mp3_queue_flush(AVFormatContext *s) · 248 unmodified lines | |||
| 387 | ff_id3v2_finish(&mp3->id3, s->pb, s->metadata_header_padding); | 387 | ff_id3v2_finish(&mp3->id3, s->pb, s->metadata_header_padding); |
| 388 | mp3_write_xing(s); | 388 | mp3_write_xing(s); |
| 389 | 389 | ||
| 390 | while (mp3->queue) { | 390 | while (mp3->queue.head) { |
| 391 | avpriv_packet_list_get(&mp3->queue, &mp3->queue_end, pkt); | 391 | avpriv_packet_list_get(&mp3->queue, pkt); |
| 392 | if (write && (ret = mp3_write_audio_packet(s, pkt)) < 0) | 392 | if (write && (ret = mp3_write_audio_packet(s, pkt)) < 0) |
| 393 | write = 0; | 393 | write = 0; |
| 394 | av_packet_unref(pkt); | 394 | av_packet_unref(pkt); |
| @@ -524,8 +524,7 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt) · 129 unmodified lines | |||
| 524 | if (pkt->stream_index == mp3->audio_stream_idx) { | 524 | if (pkt->stream_index == mp3->audio_stream_idx) { |
| 525 | if (mp3->pics_to_write) { | 525 | if (mp3->pics_to_write) { |
| 526 | /* buffer audio packets until we get all the pictures */ | 526 | /* buffer audio packets until we get all the pictures */ |
| 527 | int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end, | 527 | int ret = avpriv_packet_list_put(&mp3->queue, pkt, NULL, 0); |
| 528 | pkt, NULL, 0); | ||
| 529 | 528 | ||
| 530 | if (ret < 0) { | 529 | if (ret < 0) { |
| 531 | av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n"); | 530 | av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n"); |
| @@ -633,7 +632,7 @@ static void mp3_deinit(struct AVFormatContext *s) · 101 unmodified lines | |||
| 633 | { | 632 | { |
| 634 | MP3Context *mp3 = s->priv_data; | 633 | MP3Context *mp3 = s->priv_data; |
| 635 | 634 | ||
| 636 | avpriv_packet_list_free(&mp3->queue, &mp3->queue_end); | 635 | avpriv_packet_list_free(&mp3->queue); |
| 637 | av_freep(&mp3->xing_frame); | 636 | av_freep(&mp3->xing_frame); |
| 638 | } | 637 | } |
| 639 | 638 | ||
| @@ -809,12 +809,12 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, · 808 unmodified lines | |||
| 809 | { | 809 | { |
| 810 | int ret; | 810 | int ret; |
| 811 | FFFormatContext *const si = ffformatcontext(s); | 811 | FFFormatContext *const si = ffformatcontext(s); |
| 812 | PacketList **next_point, *this_pktl; | 812 | PacketListEntry **next_point, *this_pktl; |
| 813 | AVStream *st = s->streams[pkt->stream_index]; | 813 | AVStream *st = s->streams[pkt->stream_index]; |
| 814 | FFStream *const sti = ffstream(st); | 814 | FFStream *const sti = ffstream(st); |
| 815 | int chunked = s->max_chunk_size || s->max_chunk_duration; | 815 | int chunked = s->max_chunk_size || s->max_chunk_duration; |
| 816 | 816 | ||
| 817 | this_pktl = av_malloc(sizeof(PacketList)); | 817 | this_pktl = av_malloc(sizeof(*this_pktl)); |
| 818 | if (!this_pktl) { | 818 | if (!this_pktl) { |
| 819 | av_packet_unref(pkt); | 819 | av_packet_unref(pkt); |
| 820 | return AVERROR(ENOMEM); | 820 | return AVERROR(ENOMEM); |
| @@ -831,7 +831,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, · 10 unmodified lines | |||
| 831 | if (sti->last_in_packet_buffer) { | 831 | if (sti->last_in_packet_buffer) { |
| 832 | next_point = &(sti->last_in_packet_buffer->next); | 832 | next_point = &(sti->last_in_packet_buffer->next); |
| 833 | } else { | 833 | } else { |
| 834 | next_point = &si->packet_buffer; | 834 | next_point = &si->packet_buffer.head; |
| 835 | } | 835 | } |
| 836 | 836 | ||
| 837 | if (chunked) { | 837 | if (chunked) { |
| @@ -855,7 +855,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, · 17 unmodified lines | |||
| 855 | if (chunked && !(pkt->flags & CHUNK_START)) | 855 | if (chunked && !(pkt->flags & CHUNK_START)) |
| 856 | goto next_non_null; | 856 | goto next_non_null; |
| 857 | 857 | ||
| 858 | if (compare(s, &si->packet_buffer_end->pkt, pkt)) { | 858 | if (compare(s, &si->packet_buffer.tail->pkt, pkt)) { |
| 859 | while ( *next_point | 859 | while ( *next_point |
| 860 | && ((chunked && !((*next_point)->pkt.flags&CHUNK_START)) | 860 | && ((chunked && !((*next_point)->pkt.flags&CHUNK_START)) |
| 861 | || !compare(s, &(*next_point)->pkt, pkt))) | 861 | || !compare(s, &(*next_point)->pkt, pkt))) |
| @@ -863,12 +863,12 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, · 1 unmodified line | |||
| 863 | if (*next_point) | 863 | if (*next_point) |
| 864 | goto next_non_null; | 864 | goto next_non_null; |
| 865 | } else { | 865 | } else { |
| 866 | next_point = &(si->packet_buffer_end->next); | 866 | next_point = &(si->packet_buffer.tail->next); |
| 867 | } | 867 | } |
| 868 | } | 868 | } |
| 869 | av_assert1(!*next_point); | 869 | av_assert1(!*next_point); |
| 870 | 870 | ||
| 871 | si->packet_buffer_end = this_pktl; | 871 | si->packet_buffer.tail = this_pktl; |
| 872 | next_non_null: | 872 | next_non_null: |
| 873 | 873 | ||
| 874 | this_pktl->next = *next_point; | 874 | this_pktl->next = *next_point; |
| @@ -939,11 +939,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 64 unmodified lines | |||
| 939 | flush = 1; | 939 | flush = 1; |
| 940 | 940 | ||
| 941 | if (s->max_interleave_delta > 0 && | 941 | if (s->max_interleave_delta > 0 && |
| 942 | si->packet_buffer && | 942 | si->packet_buffer.head && |
| 943 | !flush && | 943 | !flush && |
| 944 | si->nb_interleaved_streams == stream_count+noninterleaved_count | 944 | si->nb_interleaved_streams == stream_count+noninterleaved_count |
| 945 | ) { | 945 | ) { |
| 946 | AVPacket *const top_pkt = &si->packet_buffer->pkt; | 946 | AVPacket *const top_pkt = &si->packet_buffer.head->pkt; |
| 947 | int64_t delta_dts = INT64_MIN; | 947 | int64_t delta_dts = INT64_MIN; |
| 948 | int64_t top_dts = av_rescale_q(top_pkt->dts, | 948 | int64_t top_dts = av_rescale_q(top_pkt->dts, |
| 949 | s->streams[top_pkt->stream_index]->time_base, | 949 | s->streams[top_pkt->stream_index]->time_base, |
| @@ -952,7 +952,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 2 unmodified lines | |||
| 952 | for (unsigned i = 0; i < s->nb_streams; i++) { | 952 | for (unsigned i = 0; i < s->nb_streams; i++) { |
| 953 | const AVStream *const st = s->streams[i]; | 953 | const AVStream *const st = s->streams[i]; |
| 954 | const FFStream *const sti = cffstream(st); | 954 | const FFStream *const sti = cffstream(st); |
| 955 | const PacketList *last = sti->last_in_packet_buffer; | 955 | const PacketListEntry *const last = sti->last_in_packet_buffer; |
| 956 | int64_t last_dts; | 956 | int64_t last_dts; |
| 957 | 957 | ||
| 958 | if (!last) | 958 | if (!last) |
| @@ -973,11 +973,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 14 unmodified lines | |||
| 973 | } | 973 | } |
| 974 | } | 974 | } |
| 975 | 975 | ||
| 976 | if (si->packet_buffer && | 976 | if (si->packet_buffer.head && |
| 977 | eof && | 977 | eof && |
| 978 | (s->flags & AVFMT_FLAG_SHORTEST) && | 978 | (s->flags & AVFMT_FLAG_SHORTEST) && |
| 979 | si->shortest_end == AV_NOPTS_VALUE) { | 979 | si->shortest_end == AV_NOPTS_VALUE) { |
| 980 | AVPacket *const top_pkt = &si->packet_buffer->pkt; | 980 | AVPacket *const top_pkt = &si->packet_buffer.head->pkt; |
| 981 | 981 | ||
| 982 | si->shortest_end = av_rescale_q(top_pkt->dts, | 982 | si->shortest_end = av_rescale_q(top_pkt->dts, |
| 983 | s->streams[top_pkt->stream_index]->time_base, | 983 | s->streams[top_pkt->stream_index]->time_base, |
| @@ -985,8 +985,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 1 unmodified line | |||
| 985 | } | 985 | } |
| 986 | 986 | ||
| 987 | if (si->shortest_end != AV_NOPTS_VALUE) { | 987 | if (si->shortest_end != AV_NOPTS_VALUE) { |
| 988 | while (si->packet_buffer) { | 988 | while (si->packet_buffer.head) { |
| 989 | PacketList *pktl = si->packet_buffer; | 989 | PacketListEntry *pktl = si->packet_buffer.head; |
| 990 | AVPacket *const top_pkt = &pktl->pkt; | 990 | AVPacket *const top_pkt = &pktl->pkt; |
| 991 | AVStream *const st = s->streams[top_pkt->stream_index]; | 991 | AVStream *const st = s->streams[top_pkt->stream_index]; |
| 992 | FFStream *const sti = ffstream(st); | 992 | FFStream *const sti = ffstream(st); |
| @@ -996,9 +996,9 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 3 unmodified lines | |||
| 996 | if (si->shortest_end + 1 >= top_dts) | 996 | if (si->shortest_end + 1 >= top_dts) |
| 997 | break; | 997 | break; |
| 998 | 998 | ||
| 999 | si->packet_buffer = pktl->next; | 999 | si->packet_buffer.head = pktl->next; |
| 1000 | if (!si->packet_buffer) | 1000 | if (!si->packet_buffer.head) |
| 1001 | si->packet_buffer_end = NULL; | 1001 | si->packet_buffer.tail = NULL; |
| 1002 | 1002 | ||
| 1003 | if (sti->last_in_packet_buffer == pktl) | 1003 | if (sti->last_in_packet_buffer == pktl) |
| 1004 | sti->last_in_packet_buffer = NULL; | 1004 | sti->last_in_packet_buffer = NULL; |
| @@ -1010,13 +1010,13 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 5 unmodified lines | |||
| 1010 | } | 1010 | } |
| 1011 | 1011 | ||
| 1012 | if (stream_count && flush) { | 1012 | if (stream_count && flush) { |
| 1013 | PacketList *pktl = si->packet_buffer; | 1013 | PacketListEntry *pktl = si->packet_buffer.head; |
| 1014 | AVStream *const st = s->streams[pktl->pkt.stream_index]; | 1014 | AVStream *const st = s->streams[pktl->pkt.stream_index]; |
| 1015 | FFStream *const sti = ffstream(st); | 1015 | FFStream *const sti = ffstream(st); |
| 1016 | 1016 | ||
| 1017 | if (sti->last_in_packet_buffer == pktl) | 1017 | if (sti->last_in_packet_buffer == pktl) |
| 1018 | sti->last_in_packet_buffer = NULL; | 1018 | sti->last_in_packet_buffer = NULL; |
| 1019 | avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, pkt); | 1019 | avpriv_packet_list_get(&si->packet_buffer, pkt); |
| 1020 | 1020 | ||
| 1021 | return 1; | 1021 | return 1; |
| 1022 | } else { | 1022 | } else { |
| @@ -1049,7 +1049,7 @@ int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset · 26 unmodified lines | |||
| 1049 | const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream) | 1049 | const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream) |
| 1050 | { | 1050 | { |
| 1051 | FFFormatContext *const si = ffformatcontext(s); | 1051 | FFFormatContext *const si = ffformatcontext(s); |
| 1052 | PacketList *pktl = si->packet_buffer; | 1052 | PacketListEntry *pktl = si->packet_buffer.head; |
| 1053 | while (pktl) { | 1053 | while (pktl) { |
| 1054 | if (pktl->pkt.stream_index == stream) { | 1054 | if (pktl->pkt.stream_index == stream) { |
| 1055 | return &pktl->pkt; | 1055 | return &pktl->pkt; |
| @@ -3097,9 +3097,9 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus · 3096 unmodified lines | |||
| 3097 | stream_count += !!ffstream(s->streams[i])->last_in_packet_buffer; | 3097 | stream_count += !!ffstream(s->streams[i])->last_in_packet_buffer; |
| 3098 | 3098 | ||
| 3099 | if (stream_count && (s->nb_streams == stream_count || flush)) { | 3099 | if (stream_count && (s->nb_streams == stream_count || flush)) { |
| 3100 | PacketList *pktl = si->packet_buffer; | 3100 | PacketListEntry *pktl = si->packet_buffer.head; |
| 3101 | if (s->nb_streams != stream_count) { | 3101 | if (s->nb_streams != stream_count) { |
| 3102 | PacketList *last = NULL; | 3102 | PacketListEntry *last = NULL; |
| 3103 | // find last packet in edit unit | 3103 | // find last packet in edit unit |
| 3104 | while (pktl) { | 3104 | while (pktl) { |
| 3105 | if (!stream_count || pktl->pkt.stream_index == 0) | 3105 | if (!stream_count || pktl->pkt.stream_index == 0) |
| @@ -3113,7 +3113,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus · 7 unmodified lines | |||
| 3113 | } | 3113 | } |
| 3114 | // purge packet queue | 3114 | // purge packet queue |
| 3115 | while (pktl) { | 3115 | while (pktl) { |
| 3116 | PacketList *next = pktl->next; | 3116 | PacketListEntry *next = pktl->next; |
| 3117 | av_packet_unref(&pktl->pkt); | 3117 | av_packet_unref(&pktl->pkt); |
| 3118 | av_freep(&pktl); | 3118 | av_freep(&pktl); |
| 3119 | pktl = next; | 3119 | pktl = next; |
| @@ -3121,16 +3121,16 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus · 1 unmodified line | |||
| 3121 | if (last) | 3121 | if (last) |
| 3122 | last->next = NULL; | 3122 | last->next = NULL; |
| 3123 | else { | 3123 | else { |
| 3124 | si->packet_buffer = NULL; | 3124 | si->packet_buffer.head = NULL; |
| 3125 | si->packet_buffer_end = NULL; | 3125 | si->packet_buffer.tail = NULL; |
| 3126 | goto out; | 3126 | goto out; |
| 3127 | } | 3127 | } |
| 3128 | pktl = si->packet_buffer; | 3128 | pktl = si->packet_buffer.head; |
| 3129 | } | 3129 | } |
| 3130 | 3130 | ||
| 3131 | if (ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer == pktl) | 3131 | if (ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer == pktl) |
| 3132 | ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer = NULL; | 3132 | ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer = NULL; |
| 3133 | avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, out); | 3133 | avpriv_packet_list_get(&si->packet_buffer, out); |
| 3134 | av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", out->stream_index, out->dts); | 3134 | av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", out->stream_index, out->dts); |
| 3135 | return 1; | 3135 | return 1; |
| 3136 | } else { | 3136 | } else { |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | |||
| 30 | 30 | ||
| 31 | typedef struct TTAMuxContext { | 31 | typedef struct TTAMuxContext { |
| 32 | AVIOContext *seek_table; | 32 | AVIOContext *seek_table; |
| 33 | PacketList *queue, *queue_end; | 33 | PacketList queue; |
| 34 | uint32_t nb_samples; | 34 | uint32_t nb_samples; |
| 35 | int frame_size; | 35 | int frame_size; |
| 36 | int last_frame; | 36 | int last_frame; |
| @@ -94,12 +94,11 @@ static int tta_write_packet(AVFormatContext *s, AVPacket *pkt) · 57 unmodified lines | |||
| 94 | TTAMuxContext *tta = s->priv_data; | 94 | TTAMuxContext *tta = s->priv_data; |
| 95 | int ret; | 95 | int ret; |
| 96 | 96 | ||
| 97 | ret = avpriv_packet_list_put(&tta->queue, &tta->queue_end, pkt, | 97 | ret = avpriv_packet_list_put(&tta->queue, pkt, NULL, 0); |
| 98 | NULL, 0); | ||
| 99 | if (ret < 0) { | 98 | if (ret < 0) { |
| 100 | return ret; | 99 | return ret; |
| 101 | } | 100 | } |
| 102 | pkt = &tta->queue_end->pkt; | 101 | pkt = &tta->queue.tail->pkt; |
| 103 | 102 | ||
| 104 | avio_wl32(tta->seek_table, pkt->size); | 103 | avio_wl32(tta->seek_table, pkt->size); |
| 105 | tta->nb_samples += pkt->duration; | 104 | tta->nb_samples += pkt->duration; |
| @@ -126,8 +125,8 @@ static void tta_queue_flush(AVFormatContext *s) · 20 unmodified lines | |||
| 126 | TTAMuxContext *tta = s->priv_data; | 125 | TTAMuxContext *tta = s->priv_data; |
| 127 | AVPacket *const pkt = ffformatcontext(s)->pkt; | 126 | AVPacket *const pkt = ffformatcontext(s)->pkt; |
| 128 | 127 | ||
| 129 | while (tta->queue) { | 128 | while (tta->queue.head) { |
| 130 | avpriv_packet_list_get(&tta->queue, &tta->queue_end, pkt); | 129 | avpriv_packet_list_get(&tta->queue, pkt); |
| 131 | avio_write(s->pb, pkt->data, pkt->size); | 130 | avio_write(s->pb, pkt->data, pkt->size); |
| 132 | av_packet_unref(pkt); | 131 | av_packet_unref(pkt); |
| 133 | } | 132 | } |
| @@ -163,7 +162,7 @@ static void tta_deinit(AVFormatContext *s) · 29 unmodified lines | |||
| 163 | TTAMuxContext *tta = s->priv_data; | 162 | TTAMuxContext *tta = s->priv_data; |
| 164 | 163 | ||
| 165 | ffio_free_dyn_buf(&tta->seek_table); | 164 | ffio_free_dyn_buf(&tta->seek_table); |
| 166 | avpriv_packet_list_free(&tta->queue, &tta->queue_end); | 165 | avpriv_packet_list_free(&tta->queue); |
| 167 | } | 166 | } |
| 168 | 167 | ||
| 169 | const AVOutputFormat ff_tta_muxer = { | 168 | const AVOutputFormat ff_tta_muxer = { |
| @@ -239,7 +239,6 @@ int avformat_queue_attached_pictures(AVFormatContext *s) · 238 unmodified lines | |||
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | ret = avpriv_packet_list_put(&si->raw_packet_buffer, | 241 | ret = avpriv_packet_list_put(&si->raw_packet_buffer, |
| 242 | &si->raw_packet_buffer_end, | ||
| 243 | &s->streams[i]->attached_pic, | 242 | &s->streams[i]->attached_pic, |
| 244 | av_packet_ref, 0); | 243 | av_packet_ref, 0); |
| 245 | if (ret < 0) | 244 | if (ret < 0) |
| @@ -300,9 +299,9 @@ int ff_is_intra_only(enum AVCodecID id) · 54 unmodified lines | |||
| 300 | void ff_flush_packet_queue(AVFormatContext *s) | 299 | void ff_flush_packet_queue(AVFormatContext *s) |
| 301 | { | 300 | { |
| 302 | FFFormatContext *const si = ffformatcontext(s); | 301 | FFFormatContext *const si = ffformatcontext(s); |
| 303 | avpriv_packet_list_free(&si->parse_queue, &si->parse_queue_end); | 302 | avpriv_packet_list_free(&si->parse_queue); |
| 304 | avpriv_packet_list_free(&si->packet_buffer, &si->packet_buffer_end); | 303 | avpriv_packet_list_free(&si->packet_buffer); |
| 305 | avpriv_packet_list_free(&si->raw_packet_buffer, &si->raw_packet_buffer_end); | 304 | avpriv_packet_list_free(&si->raw_packet_buffer); |
| 306 | 305 | ||
| 307 | si->raw_packet_buffer_size = 0; | 306 | si->raw_packet_buffer_size = 0; |
| 308 | } | 307 | } |