Core framework and AV1 only for now. This will be useful in an upcoming commit, where CBS will be utilized by a module outside libavcodec.
Unified · Split
| @@ -18,8 +18,6 @@ · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | #include <string.h> |
| 20 | 20 | |
| 21 | −#include "config.h" | |
| 22 | − | |
| 23 | 21 | #include "libavutil/avassert.h" |
| 24 | 22 | #include "libavutil/buffer.h" |
| 25 | 23 | #include "libavutil/common.h" |
| @@ -33,61 +31,61 @@ · 7 unmodified lines | ||
| 33 | 31 | |
| 34 | 32 | |
| 35 | 33 | static const CodedBitstreamType *const cbs_type_table[] = { |
| 36 | −#if CONFIG_CBS_AV1 | |
| 37 | − &ff_cbs_type_av1, | |
| 34 | +#if CBS_AV1 | |
| 35 | + &CBS_FUNC(type_av1), | |
| 38 | 36 | #endif |
| 39 | −#if CONFIG_CBS_H264 | |
| 40 | − &ff_cbs_type_h264, | |
| 37 | +#if CBS_H264 | |
| 38 | + &CBS_FUNC(type_h264), | |
| 41 | 39 | #endif |
| 42 | −#if CONFIG_CBS_H265 | |
| 43 | − &ff_cbs_type_h265, | |
| 40 | +#if CBS_H265 | |
| 41 | + &CBS_FUNC(type_h265), | |
| 44 | 42 | #endif |
| 45 | −#if CONFIG_CBS_H266 | |
| 46 | − &ff_cbs_type_h266, | |
| 43 | +#if CBS_H266 | |
| 44 | + &CBS_FUNC(type_h266), | |
| 47 | 45 | #endif |
| 48 | −#if CONFIG_CBS_JPEG | |
| 49 | − &ff_cbs_type_jpeg, | |
| 46 | +#if CBS_JPEG | |
| 47 | + &CBS_FUNC(type_jpeg), | |
| 50 | 48 | #endif |
| 51 | −#if CONFIG_CBS_MPEG2 | |
| 52 | − &ff_cbs_type_mpeg2, | |
| 49 | +#if CBS_MPEG2 | |
| 50 | + &CBS_FUNC(type_mpeg2), | |
| 53 | 51 | #endif |
| 54 | −#if CONFIG_CBS_VP8 | |
| 55 | − &ff_cbs_type_vp8, | |
| 52 | +#if CBS_VP8 | |
| 53 | + &CBS_FUNC(type_vp8), | |
| 56 | 54 | #endif |
| 57 | −#if CONFIG_CBS_VP9 | |
| 58 | − &ff_cbs_type_vp9, | |
| 55 | +#if CBS_VP9 | |
| 56 | + &CBS_FUNC(type_vp9), | |
| 59 | 57 | #endif |
| 60 | 58 | }; |
| 61 | 59 | |
| 62 | −const enum AVCodecID ff_cbs_all_codec_ids[] = { | |
| 63 | −#if CONFIG_CBS_AV1 | |
| 60 | +const enum AVCodecID CBS_FUNC(all_codec_ids)[] = { | |
| 61 | +#if CBS_AV1 | |
| 64 | 62 | AV_CODEC_ID_AV1, |
| 65 | 63 | #endif |
| 66 | −#if CONFIG_CBS_H264 | |
| 64 | +#if CBS_H264 | |
| 67 | 65 | AV_CODEC_ID_H264, |
| 68 | 66 | #endif |
| 69 | −#if CONFIG_CBS_H265 | |
| 67 | +#if CBS_H265 | |
| 70 | 68 | AV_CODEC_ID_H265, |
| 71 | 69 | #endif |
| 72 | −#if CONFIG_CBS_H266 | |
| 70 | +#if CBS_H266 | |
| 73 | 71 | AV_CODEC_ID_H266, |
| 74 | 72 | #endif |
| 75 | −#if CONFIG_CBS_JPEG | |
| 73 | +#if CBS_JPEG | |
| 76 | 74 | AV_CODEC_ID_MJPEG, |
| 77 | 75 | #endif |
| 78 | −#if CONFIG_CBS_MPEG2 | |
| 76 | +#if CBS_MPEG2 | |
| 79 | 77 | AV_CODEC_ID_MPEG2VIDEO, |
| 80 | 78 | #endif |
| 81 | −#if CONFIG_CBS_VP8 | |
| 79 | +#if CBS_VP8 | |
| 82 | 80 | AV_CODEC_ID_VP8, |
| 83 | 81 | #endif |
| 84 | −#if CONFIG_CBS_VP9 | |
| 82 | +#if CBS_VP9 | |
| 85 | 83 | AV_CODEC_ID_VP9, |
| 86 | 84 | #endif |
| 87 | 85 | AV_CODEC_ID_NONE |
| 88 | 86 | }; |
| 89 | 87 | |
| 90 | −av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr, | |
| 88 | +av_cold int CBS_FUNC(init)(CodedBitstreamContext **ctx_ptr, | |
| 91 | 89 | enum AVCodecID codec_id, void *log_ctx) |
| 92 | 90 | { |
| 93 | 91 | CodedBitstreamContext *ctx; |
| @@ -133,13 +131,13 @@ av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr, · 39 unmodified lines | ||
| 133 | 131 | return 0; |
| 134 | 132 | } |
| 135 | 133 | |
| 136 | −av_cold void ff_cbs_flush(CodedBitstreamContext *ctx) | |
| 134 | +av_cold void CBS_FUNC(flush)(CodedBitstreamContext *ctx) | |
| 137 | 135 | { |
| 138 | 136 | if (ctx->codec->flush) |
| 139 | 137 | ctx->codec->flush(ctx); |
| 140 | 138 | } |
| 141 | 139 | |
| 142 | −av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr) | |
| 140 | +av_cold void CBS_FUNC(close)(CodedBitstreamContext **ctx_ptr) | |
| 143 | 141 | { |
| 144 | 142 | CodedBitstreamContext *ctx = *ctx_ptr; |
| 145 | 143 | |
| @@ -169,7 +167,7 @@ static void cbs_unit_uninit(CodedBitstreamUnit *unit) · 23 unmodified lines | ||
| 169 | 167 | unit->data_bit_padding = 0; |
| 170 | 168 | } |
| 171 | 169 | |
| 172 | −void ff_cbs_fragment_reset(CodedBitstreamFragment *frag) | |
| 170 | +void CBS_FUNC(fragment_reset)(CodedBitstreamFragment *frag) | |
| 173 | 171 | { |
| 174 | 172 | int i; |
| 175 | 173 | |
| @@ -183,14 +181,15 @@ void ff_cbs_fragment_reset(CodedBitstreamFragment *frag) · 7 unmodified lines | ||
| 183 | 181 | frag->data_bit_padding = 0; |
| 184 | 182 | } |
| 185 | 183 | |
| 186 | −av_cold void ff_cbs_fragment_free(CodedBitstreamFragment *frag) | |
| 184 | +av_cold void CBS_FUNC(fragment_free)(CodedBitstreamFragment *frag) | |
| 187 | 185 | { |
| 188 | − ff_cbs_fragment_reset(frag); | |
| 186 | + CBS_FUNC(fragment_reset)(frag); | |
| 189 | 187 | |
| 190 | 188 | av_freep(&frag->units); |
| 191 | 189 | frag->nb_units_allocated = 0; |
| 192 | 190 | } |
| 193 | 191 | |
| 192 | +#if CBS_READ | |
| 194 | 193 | static int cbs_read_fragment_content(CodedBitstreamContext *ctx, |
| 195 | 194 | CodedBitstreamFragment *frag) |
| 196 | 195 | { |
| @@ -283,7 +282,7 @@ static int cbs_read_data(CodedBitstreamContext *ctx, · 86 unmodified lines | ||
| 283 | 282 | return cbs_read_fragment_content(ctx, frag); |
| 284 | 283 | } |
| 285 | 284 | |
| 286 | −int ff_cbs_read_extradata(CodedBitstreamContext *ctx, | |
| 285 | +int CBS_FUNC(read_extradata)(CodedBitstreamContext *ctx, | |
| 287 | 286 | CodedBitstreamFragment *frag, |
| 288 | 287 | const AVCodecParameters *par) |
| 289 | 288 | { |
| @@ -292,7 +291,7 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, · 2 unmodified lines | ||
| 292 | 291 | par->extradata_size, 1); |
| 293 | 292 | } |
| 294 | 293 | |
| 295 | −int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, | |
| 294 | +int CBS_FUNC(read_extradata_from_codec)(CodedBitstreamContext *ctx, | |
| 296 | 295 | CodedBitstreamFragment *frag, |
| 297 | 296 | const AVCodecContext *avctx) |
| 298 | 297 | { |
| @@ -301,7 +300,7 @@ int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, · 2 unmodified lines | ||
| 301 | 300 | avctx->extradata_size, 1); |
| 302 | 301 | } |
| 303 | 302 | |
| 304 | −int ff_cbs_read_packet(CodedBitstreamContext *ctx, | |
| 303 | +int CBS_FUNC(read_packet)(CodedBitstreamContext *ctx, | |
| 305 | 304 | CodedBitstreamFragment *frag, |
| 306 | 305 | const AVPacket *pkt) |
| 307 | 306 | { |
| @@ -309,7 +308,7 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, · 1 unmodified line | ||
| 309 | 308 | pkt->data, pkt->size, 0); |
| 310 | 309 | } |
| 311 | 310 | |
| 312 | −int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, | |
| 311 | +int CBS_FUNC(read_packet_side_data)(CodedBitstreamContext *ctx, | |
| 313 | 312 | CodedBitstreamFragment *frag, |
| 314 | 313 | const AVPacket *pkt) |
| 315 | 314 | { |
| @@ -322,14 +321,16 @@ int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, · 6 unmodified lines | ||
| 322 | 321 | side_data, side_data_size, 1); |
| 323 | 322 | } |
| 324 | 323 | |
| 325 | −int ff_cbs_read(CodedBitstreamContext *ctx, | |
| 324 | +int CBS_FUNC(read)(CodedBitstreamContext *ctx, | |
| 326 | 325 | CodedBitstreamFragment *frag, |
| 327 | 326 | const uint8_t *data, size_t size) |
| 328 | 327 | { |
| 329 | 328 | return cbs_read_data(ctx, frag, NULL, |
| 330 | 329 | data, size, 0); |
| 331 | 330 | } |
| 331 | +#endif | |
| 332 | 332 | |
| 333 | +#if CBS_WRITE | |
| 333 | 334 | /** |
| 334 | 335 | * Allocate a new internal data buffer of the given size in the unit. |
| 335 | 336 | * |
| @@ -406,7 +407,7 @@ static int cbs_write_unit_data(CodedBitstreamContext *ctx, · 70 unmodified lines | ||
| 406 | 407 | return 0; |
| 407 | 408 | } |
| 408 | 409 | |
| 409 | −int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, | |
| 410 | +int CBS_FUNC(write_fragment_data)(CodedBitstreamContext *ctx, | |
| 410 | 411 | CodedBitstreamFragment *frag) |
| 411 | 412 | { |
| 412 | 413 | int err, i; |
| @@ -442,13 +443,13 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, · 29 unmodified lines | ||
| 442 | 443 | return 0; |
| 443 | 444 | } |
| 444 | 445 | |
| 445 | −int ff_cbs_write_extradata(CodedBitstreamContext *ctx, | |
| 446 | +int CBS_FUNC(write_extradata)(CodedBitstreamContext *ctx, | |
| 446 | 447 | AVCodecParameters *par, |
| 447 | 448 | CodedBitstreamFragment *frag) |
| 448 | 449 | { |
| 449 | 450 | int err; |
| 450 | 451 | |
| 451 | − err = ff_cbs_write_fragment_data(ctx, frag); | |
| 452 | + err = CBS_FUNC(write_fragment_data)(ctx, frag); | |
| 452 | 453 | if (err < 0) |
| 453 | 454 | return err; |
| 454 | 455 | |
| @@ -471,14 +472,14 @@ int ff_cbs_write_extradata(CodedBitstreamContext *ctx, · 16 unmodified lines | ||
| 471 | 472 | return 0; |
| 472 | 473 | } |
| 473 | 474 | |
| 474 | −int ff_cbs_write_packet(CodedBitstreamContext *ctx, | |
| 475 | +int CBS_FUNC(write_packet)(CodedBitstreamContext *ctx, | |
| 475 | 476 | AVPacket *pkt, |
| 476 | 477 | CodedBitstreamFragment *frag) |
| 477 | 478 | { |
| 478 | 479 | AVBufferRef *buf; |
| 479 | 480 | int err; |
| 480 | 481 | |
| 481 | − err = ff_cbs_write_fragment_data(ctx, frag); | |
| 482 | + err = CBS_FUNC(write_fragment_data)(ctx, frag); | |
| 482 | 483 | if (err < 0) |
| 483 | 484 | return err; |
| 484 | 485 | |
| @@ -494,22 +495,26 @@ int ff_cbs_write_packet(CodedBitstreamContext *ctx, · 9 unmodified lines | ||
| 494 | 495 | |
| 495 | 496 | return 0; |
| 496 | 497 | } |
| 498 | +#endif | |
| 497 | 499 | |
| 498 | 500 | |
| 499 | −void ff_cbs_trace_header(CodedBitstreamContext *ctx, | |
| 501 | +void CBS_FUNC(trace_header)(CodedBitstreamContext *ctx, | |
| 500 | 502 | const char *name) |
| 501 | 503 | { |
| 504 | +#if CBS_TRACE | |
| 502 | 505 | if (!ctx->trace_enable) |
| 503 | 506 | return; |
| 504 | 507 | |
| 505 | 508 | av_log(ctx->log_ctx, ctx->trace_level, "%s\n", name); |
| 509 | +#endif | |
| 506 | 510 | } |
| 507 | 511 | |
| 508 | −void ff_cbs_trace_read_log(void *trace_context, | |
| 512 | +void CBS_FUNC(trace_read_log)(void *trace_context, | |
| 509 | 513 | GetBitContext *gbc, int length, |
| 510 | 514 | const char *str, const int *subscripts, |
| 511 | 515 | int64_t value) |
| 512 | 516 | { |
| 517 | +#if CBS_TRACE | |
| 513 | 518 | CodedBitstreamContext *ctx = trace_context; |
| 514 | 519 | char name[256]; |
| 515 | 520 | char bits[256]; |
| @@ -561,13 +566,15 @@ void ff_cbs_trace_read_log(void *trace_context, · 45 unmodified lines | ||
| 561 | 566 | |
| 562 | 567 | av_log(ctx->log_ctx, ctx->trace_level, "%-10d %s%*s = %"PRId64"\n", |
| 563 | 568 | position, name, pad, bits, value); |
| 569 | +#endif | |
| 564 | 570 | } |
| 565 | 571 | |
| 566 | −void ff_cbs_trace_write_log(void *trace_context, | |
| 572 | +void CBS_FUNC(trace_write_log)(void *trace_context, | |
| 567 | 573 | PutBitContext *pbc, int length, |
| 568 | 574 | const char *str, const int *subscripts, |
| 569 | 575 | int64_t value) |
| 570 | 576 | { |
| 577 | +#if CBS_TRACE | |
| 571 | 578 | CodedBitstreamContext *ctx = trace_context; |
| 572 | 579 | |
| 573 | 580 | // Ensure that the syntax element is written to the output buffer, |
| @@ -590,9 +597,11 @@ void ff_cbs_trace_write_log(void *trace_context, · 16 unmodified lines | ||
| 590 | 597 | |
| 591 | 598 | skip_bits_long(&gbc, position - length); |
| 592 | 599 | |
| 593 | − ff_cbs_trace_read_log(ctx, &gbc, length, str, subscripts, value); | |
| 600 | + CBS_FUNC(trace_read_log)(ctx, &gbc, length, str, subscripts, value); | |
| 601 | +#endif | |
| 594 | 602 | } |
| 595 | 603 | |
| 604 | +#if CBS_READ | |
| 596 | 605 | static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx, |
| 597 | 606 | GetBitContext *gbc, |
| 598 | 607 | int width, const char *name, |
| @@ -628,7 +637,7 @@ static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx, · 29 unmodified lines | ||
| 628 | 637 | return 0; |
| 629 | 638 | } |
| 630 | 639 | |
| 631 | −int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 640 | +int CBS_FUNC(read_unsigned)(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 632 | 641 | int width, const char *name, |
| 633 | 642 | const int *subscripts, uint32_t *write_to, |
| 634 | 643 | uint32_t range_min, uint32_t range_max) |
| @@ -637,14 +646,16 @@ int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, · 2 unmodified lines | ||
| 637 | 646 | write_to, range_min, range_max); |
| 638 | 647 | } |
| 639 | 648 | |
| 640 | −int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 649 | +int CBS_FUNC(read_simple_unsigned)(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 641 | 650 | int width, const char *name, uint32_t *write_to) |
| 642 | 651 | { |
| 643 | 652 | return cbs_read_unsigned(ctx, gbc, width, name, NULL, |
| 644 | 653 | write_to, 0, UINT32_MAX); |
| 645 | 654 | } |
| 655 | +#endif | |
| 646 | 656 | |
| 647 | −int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 657 | +#if CBS_WRITE | |
| 658 | +int CBS_FUNC(write_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 648 | 659 | int width, const char *name, |
| 649 | 660 | const int *subscripts, uint32_t value, |
| 650 | 661 | uint32_t range_min, uint32_t range_max) |
| @@ -673,14 +684,16 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, · 22 unmodified lines | ||
| 673 | 684 | return 0; |
| 674 | 685 | } |
| 675 | 686 | |
| 676 | −int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 687 | +int CBS_FUNC(write_simple_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 677 | 688 | int width, const char *name, uint32_t value) |
| 678 | 689 | { |
| 679 | − return ff_cbs_write_unsigned(ctx, pbc, width, name, NULL, | |
| 690 | + return CBS_FUNC(write_unsigned)(ctx, pbc, width, name, NULL, | |
| 680 | 691 | value, 0, MAX_UINT_BITS(width)); |
| 681 | 692 | } |
| 693 | +#endif | |
| 682 | 694 | |
| 683 | −int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 695 | +#if CBS_READ | |
| 696 | +int CBS_FUNC(read_signed)(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 684 | 697 | int width, const char *name, |
| 685 | 698 | const int *subscripts, int32_t *write_to, |
| 686 | 699 | int32_t range_min, int32_t range_max) |
| @@ -711,8 +724,10 @@ int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, · 24 unmodified lines | ||
| 711 | 724 | *write_to = value; |
| 712 | 725 | return 0; |
| 713 | 726 | } |
| 727 | +#endif | |
| 714 | 728 | |
| 715 | −int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 729 | +#if CBS_WRITE | |
| 730 | +int CBS_FUNC(write_signed)(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 716 | 731 | int width, const char *name, |
| 717 | 732 | const int *subscripts, int32_t value, |
| 718 | 733 | int32_t range_min, int32_t range_max) |
| @@ -740,6 +755,7 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, · 21 unmodified lines | ||
| 740 | 755 | |
| 741 | 756 | return 0; |
| 742 | 757 | } |
| 758 | +#endif | |
| 743 | 759 | |
| 744 | 760 | |
| 745 | 761 | static int cbs_insert_unit(CodedBitstreamFragment *frag, |
| @@ -780,7 +796,7 @@ static int cbs_insert_unit(CodedBitstreamFragment *frag, · 34 unmodified lines | ||
| 780 | 796 | return 0; |
| 781 | 797 | } |
| 782 | 798 | |
| 783 | −int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, | |
| 799 | +int CBS_FUNC(insert_unit_content)(CodedBitstreamFragment *frag, | |
| 784 | 800 | int position, |
| 785 | 801 | CodedBitstreamUnitType type, |
| 786 | 802 | void *content, |
| @@ -847,7 +863,7 @@ static int cbs_insert_unit_data(CodedBitstreamFragment *frag, · 60 unmodified lines | ||
| 847 | 863 | return 0; |
| 848 | 864 | } |
| 849 | 865 | |
| 850 | −int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, | |
| 866 | +int CBS_FUNC(append_unit_data)(CodedBitstreamFragment *frag, | |
| 851 | 867 | CodedBitstreamUnitType type, |
| 852 | 868 | uint8_t *data, size_t data_size, |
| 853 | 869 | AVBufferRef *data_buf) |
| @@ -857,7 +873,7 @@ int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, · 3 unmodified lines | ||
| 857 | 873 | frag->nb_units); |
| 858 | 874 | } |
| 859 | 875 | |
| 860 | −void ff_cbs_delete_unit(CodedBitstreamFragment *frag, | |
| 876 | +void CBS_FUNC(delete_unit)(CodedBitstreamFragment *frag, | |
| 861 | 877 | int position) |
| 862 | 878 | { |
| 863 | 879 | av_assert0(0 <= position && position < frag->nb_units |
| @@ -920,7 +936,7 @@ static void *cbs_alloc_content(const CodedBitstreamUnitTypeDescriptor *desc) · 56 unmodified lines | ||
| 920 | 936 | : cbs_default_free_unit_content); |
| 921 | 937 | } |
| 922 | 938 | |
| 923 | −int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, | |
| 939 | +int CBS_FUNC(alloc_unit_content)(CodedBitstreamContext *ctx, | |
| 924 | 940 | CodedBitstreamUnit *unit) |
| 925 | 941 | { |
| 926 | 942 | const CodedBitstreamUnitTypeDescriptor *desc; |
| @@ -1032,7 +1048,7 @@ static int cbs_clone_unit_content(CodedBitstreamContext *ctx, · 105 unmodified lines | ||
| 1032 | 1048 | return 0; |
| 1033 | 1049 | } |
| 1034 | 1050 | |
| 1035 | −int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx, | |
| 1051 | +int CBS_FUNC(make_unit_refcounted)(CodedBitstreamContext *ctx, | |
| 1036 | 1052 | CodedBitstreamUnit *unit) |
| 1037 | 1053 | { |
| 1038 | 1054 | av_assert0(unit->content); |
| @@ -1041,7 +1057,7 @@ int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx, · 2 unmodified lines | ||
| 1041 | 1057 | return cbs_clone_unit_content(ctx, unit); |
| 1042 | 1058 | } |
| 1043 | 1059 | |
| 1044 | −int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx, | |
| 1060 | +int CBS_FUNC(make_unit_writable)(CodedBitstreamContext *ctx, | |
| 1045 | 1061 | CodedBitstreamUnit *unit) |
| 1046 | 1062 | { |
| 1047 | 1063 | void *ref = unit->content_ref; |
| @@ -1058,7 +1074,7 @@ int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx, · 10 unmodified lines | ||
| 1058 | 1074 | return 0; |
| 1059 | 1075 | } |
| 1060 | 1076 | |
| 1061 | −void ff_cbs_discard_units(CodedBitstreamContext *ctx, | |
| 1077 | +void CBS_FUNC(discard_units)(CodedBitstreamContext *ctx, | |
| 1062 | 1078 | CodedBitstreamFragment *frag, |
| 1063 | 1079 | enum AVDiscard skip, |
| 1064 | 1080 | int flags) |
| @@ -1070,11 +1086,11 @@ void ff_cbs_discard_units(CodedBitstreamContext *ctx, · 5 unmodified lines | ||
| 1070 | 1086 | if (ctx->codec->discarded_unit(ctx, &frag->units[i], skip)) { |
| 1071 | 1087 | // discard all units |
| 1072 | 1088 | if (!(flags & DISCARD_FLAG_KEEP_NON_VCL)) { |
| 1073 | − ff_cbs_fragment_free(frag); | |
| 1089 | + CBS_FUNC(fragment_free)(frag); | |
| 1074 | 1090 | return; |
| 1075 | 1091 | } |
| 1076 | 1092 | |
| 1077 | − ff_cbs_delete_unit(frag, i); | |
| 1093 | + CBS_FUNC(delete_unit)(frag, i); | |
| 1078 | 1094 | } |
| 1079 | 1095 | } |
| 1080 | 1096 | } |
| @@ -29,6 +29,13 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "defs.h" |
| 30 | 30 | #include "packet.h" |
| 31 | 31 | |
| 32 | +#ifndef CBS_PREFIX | |
| 33 | +#define CBS_PREFIX cbs | |
| 34 | +#endif | |
| 35 | + | |
| 36 | +#define CBS_FUNC_PREFIX_NAME(prefix, name) ff_ ## prefix ## _ ## name | |
| 37 | +#define CBS_FUNC_NAME(prefix, name) CBS_FUNC_PREFIX_NAME(prefix, name) | |
| 38 | +#define CBS_FUNC(name) CBS_FUNC_NAME(CBS_PREFIX, name) | |
| 32 | 39 | |
| 33 | 40 | /* |
| 34 | 41 | * This defines a framework for converting between a coded bitstream |
| @@ -294,24 +301,24 @@ typedef struct CodedBitstreamContext { · 259 unmodified lines | ||
| 294 | 301 | * |
| 295 | 302 | * Terminated by AV_CODEC_ID_NONE. |
| 296 | 303 | */ |
| 297 | −extern const enum AVCodecID ff_cbs_all_codec_ids[]; | |
| 304 | +extern const enum AVCodecID CBS_FUNC(all_codec_ids)[]; | |
| 298 | 305 | |
| 299 | 306 | |
| 300 | 307 | /** |
| 301 | 308 | * Create and initialise a new context for the given codec. |
| 302 | 309 | */ |
| 303 | −int ff_cbs_init(CodedBitstreamContext **ctx, | |
| 310 | +int CBS_FUNC(init)(CodedBitstreamContext **ctx, | |
| 304 | 311 | enum AVCodecID codec_id, void *log_ctx); |
| 305 | 312 | |
| 306 | 313 | /** |
| 307 | 314 | * Reset all internal state in a context. |
| 308 | 315 | */ |
| 309 | −void ff_cbs_flush(CodedBitstreamContext *ctx); | |
| 316 | +void CBS_FUNC(flush)(CodedBitstreamContext *ctx); | |
| 310 | 317 | |
| 311 | 318 | /** |
| 312 | 319 | * Close a context and free all internal state. |
| 313 | 320 | */ |
| 314 | −void ff_cbs_close(CodedBitstreamContext **ctx); | |
| 321 | +void CBS_FUNC(close)(CodedBitstreamContext **ctx); | |
| 315 | 322 | |
| 316 | 323 | |
| 317 | 324 | /** |
| @@ -325,7 +332,7 @@ void ff_cbs_close(CodedBitstreamContext **ctx); · 7 unmodified lines | ||
| 325 | 332 | * The fragment must have been zeroed or reset via ff_cbs_fragment_reset |
| 326 | 333 | * before use. |
| 327 | 334 | */ |
| 328 | −int ff_cbs_read_extradata(CodedBitstreamContext *ctx, | |
| 335 | +int CBS_FUNC(read_extradata)(CodedBitstreamContext *ctx, | |
| 329 | 336 | CodedBitstreamFragment *frag, |
| 330 | 337 | const AVCodecParameters *par); |
| 331 | 338 | |
| @@ -336,11 +343,11 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, · 4 unmodified lines | ||
| 336 | 343 | * This acts identical to ff_cbs_read_extradata() for the case where |
| 337 | 344 | * you already have a codec context. |
| 338 | 345 | */ |
| 339 | −int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, | |
| 346 | +int CBS_FUNC(read_extradata_from_codec)(CodedBitstreamContext *ctx, | |
| 340 | 347 | CodedBitstreamFragment *frag, |
| 341 | 348 | const struct AVCodecContext *avctx); |
| 342 | 349 | |
| 343 | −int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, | |
| 350 | +int CBS_FUNC(read_packet_side_data)(CodedBitstreamContext *ctx, | |
| 344 | 351 | CodedBitstreamFragment *frag, |
| 345 | 352 | const AVPacket *pkt); |
| 346 | 353 | |
| @@ -355,7 +362,7 @@ int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, · 8 unmodified lines | ||
| 355 | 362 | * The fragment must have been zeroed or reset via ff_cbs_fragment_reset |
| 356 | 363 | * before use. |
| 357 | 364 | */ |
| 358 | −int ff_cbs_read_packet(CodedBitstreamContext *ctx, | |
| 365 | +int CBS_FUNC(read_packet)(CodedBitstreamContext *ctx, | |
| 359 | 366 | CodedBitstreamFragment *frag, |
| 360 | 367 | const AVPacket *pkt); |
| 361 | 368 | |
| @@ -370,7 +377,7 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, · 8 unmodified lines | ||
| 370 | 377 | * The fragment must have been zeroed or reset via ff_cbs_fragment_reset |
| 371 | 378 | * before use. |
| 372 | 379 | */ |
| 373 | −int ff_cbs_read(CodedBitstreamContext *ctx, | |
| 380 | +int CBS_FUNC(read)(CodedBitstreamContext *ctx, | |
| 374 | 381 | CodedBitstreamFragment *frag, |
| 375 | 382 | const uint8_t *data, size_t size); |
| 376 | 383 | |
| @@ -387,7 +394,7 @@ int ff_cbs_read(CodedBitstreamContext *ctx, · 10 unmodified lines | ||
| 387 | 394 | * with any persistent data from the fragment which may be required to |
| 388 | 395 | * write following fragments (e.g. parameter sets). |
| 389 | 396 | */ |
| 390 | −int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, | |
| 397 | +int CBS_FUNC(write_fragment_data)(CodedBitstreamContext *ctx, | |
| 391 | 398 | CodedBitstreamFragment *frag); |
| 392 | 399 | |
| 393 | 400 | /** |
| @@ -396,7 +403,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, · 2 unmodified lines | ||
| 396 | 403 | * Modifies context and fragment as ff_cbs_write_fragment_data does and |
| 397 | 404 | * replaces any existing extradata in the structure. |
| 398 | 405 | */ |
| 399 | −int ff_cbs_write_extradata(CodedBitstreamContext *ctx, | |
| 406 | +int CBS_FUNC(write_extradata)(CodedBitstreamContext *ctx, | |
| 400 | 407 | AVCodecParameters *par, |
| 401 | 408 | CodedBitstreamFragment *frag); |
| 402 | 409 | |
| @@ -410,7 +417,7 @@ int ff_cbs_write_extradata(CodedBitstreamContext *ctx, · 7 unmodified lines | ||
| 410 | 417 | * fragment; other fields are not touched. On failure, the packet is not |
| 411 | 418 | * touched at all. |
| 412 | 419 | */ |
| 413 | −int ff_cbs_write_packet(CodedBitstreamContext *ctx, | |
| 420 | +int CBS_FUNC(write_packet)(CodedBitstreamContext *ctx, | |
| 414 | 421 | AVPacket *pkt, |
| 415 | 422 | CodedBitstreamFragment *frag); |
| 416 | 423 | |
| @@ -419,20 +426,20 @@ int ff_cbs_write_packet(CodedBitstreamContext *ctx, · 2 unmodified lines | ||
| 419 | 426 | * Free the units contained in a fragment as well as the fragment's |
| 420 | 427 | * own data buffer, but not the units array itself. |
| 421 | 428 | */ |
| 422 | −void ff_cbs_fragment_reset(CodedBitstreamFragment *frag); | |
| 429 | +void CBS_FUNC(fragment_reset)(CodedBitstreamFragment *frag); | |
| 423 | 430 | |
| 424 | 431 | /** |
| 425 | 432 | * Free the units array of a fragment in addition to what |
| 426 | 433 | * ff_cbs_fragment_reset does. |
| 427 | 434 | */ |
| 428 | −void ff_cbs_fragment_free(CodedBitstreamFragment *frag); | |
| 435 | +void CBS_FUNC(fragment_free)(CodedBitstreamFragment *frag); | |
| 429 | 436 | |
| 430 | 437 | /** |
| 431 | 438 | * Allocate a new internal content buffer matching the type of the unit. |
| 432 | 439 | * |
| 433 | 440 | * The content will be zeroed. |
| 434 | 441 | */ |
| 435 | −int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, | |
| 442 | +int CBS_FUNC(alloc_unit_content)(CodedBitstreamContext *ctx, | |
| 436 | 443 | CodedBitstreamUnit *unit); |
| 437 | 444 | |
| 438 | 445 | /** |
| @@ -443,7 +450,7 @@ int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, · 4 unmodified lines | ||
| 443 | 450 | * The content structure continues to be owned by the caller if |
| 444 | 451 | * content_ref is not supplied. |
| 445 | 452 | */ |
| 446 | −int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, | |
| 453 | +int CBS_FUNC(insert_unit_content)(CodedBitstreamFragment *frag, | |
| 447 | 454 | int position, |
| 448 | 455 | CodedBitstreamUnitType type, |
| 449 | 456 | void *content, |
| @@ -456,7 +463,7 @@ int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, · 6 unmodified lines | ||
| 456 | 463 | * av_malloc() and will on success become owned by the unit after this |
| 457 | 464 | * call or freed on error. |
| 458 | 465 | */ |
| 459 | −int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, | |
| 466 | +int CBS_FUNC(append_unit_data)(CodedBitstreamFragment *frag, | |
| 460 | 467 | CodedBitstreamUnitType type, |
| 461 | 468 | uint8_t *data, size_t data_size, |
| 462 | 469 | AVBufferRef *data_buf); |
| @@ -466,7 +473,7 @@ int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, · 3 unmodified lines | ||
| 466 | 473 | * |
| 467 | 474 | * Requires position to be >= 0 and < frag->nb_units. |
| 468 | 475 | */ |
| 469 | −void ff_cbs_delete_unit(CodedBitstreamFragment *frag, | |
| 476 | +void CBS_FUNC(delete_unit)(CodedBitstreamFragment *frag, | |
| 470 | 477 | int position); |
| 471 | 478 | |
| 472 | 479 | |
| @@ -479,7 +486,7 @@ void ff_cbs_delete_unit(CodedBitstreamFragment *frag, · 6 unmodified lines | ||
| 479 | 486 | * It is not valid to call this function on a unit which does not have |
| 480 | 487 | * decomposed content. |
| 481 | 488 | */ |
| 482 | −int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx, | |
| 489 | +int CBS_FUNC(make_unit_refcounted)(CodedBitstreamContext *ctx, | |
| 483 | 490 | CodedBitstreamUnit *unit); |
| 484 | 491 | |
| 485 | 492 | /** |
| @@ -495,7 +502,7 @@ int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx, · 9 unmodified lines | ||
| 495 | 502 | * It is not valid to call this function on a unit which does not have |
| 496 | 503 | * decomposed content. |
| 497 | 504 | */ |
| 498 | −int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx, | |
| 505 | +int CBS_FUNC(make_unit_writable)(CodedBitstreamContext *ctx, | |
| 499 | 506 | CodedBitstreamUnit *unit); |
| 500 | 507 | |
| 501 | 508 | enum CbsDiscardFlags { |
| @@ -510,7 +517,7 @@ enum CbsDiscardFlags { · 8 unmodified lines | ||
| 510 | 517 | /** |
| 511 | 518 | * Discard units accroding to 'skip'. |
| 512 | 519 | */ |
| 513 | −void ff_cbs_discard_units(CodedBitstreamContext *ctx, | |
| 520 | +void CBS_FUNC(discard_units)(CodedBitstreamContext *ctx, | |
| 514 | 521 | CodedBitstreamFragment *frag, |
| 515 | 522 | enum AVDiscard skip, |
| 516 | 523 | int flags); |
| @@ -522,7 +529,7 @@ void ff_cbs_discard_units(CodedBitstreamContext *ctx, · 5 unmodified lines | ||
| 522 | 529 | * |
| 523 | 530 | * Trace context should be set to the CodedBitstreamContext. |
| 524 | 531 | */ |
| 525 | −void ff_cbs_trace_read_log(void *trace_context, | |
| 532 | +void CBS_FUNC(trace_read_log)(void *trace_context, | |
| 526 | 533 | struct GetBitContext *gbc, int length, |
| 527 | 534 | const char *str, const int *subscripts, |
| 528 | 535 | int64_t value); |
| @@ -533,7 +540,7 @@ void ff_cbs_trace_read_log(void *trace_context, · 4 unmodified lines | ||
| 533 | 540 | * |
| 534 | 541 | * Trace context should be set to the CodedBitstreamContext. |
| 535 | 542 | */ |
| 536 | −void ff_cbs_trace_write_log(void *trace_context, | |
| 543 | +void CBS_FUNC(trace_write_log)(void *trace_context, | |
| 537 | 544 | struct PutBitContext *pbc, int length, |
| 538 | 545 | const char *str, const int *subscripts, |
| 539 | 546 | int64_t value); |
| @@ -27,6 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "libavutil/refstruct.h" |
| 28 | 28 | |
| 29 | 29 | |
| 30 | +#if CBS_READ | |
| 30 | 31 | static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc, |
| 31 | 32 | const char *name, uint32_t *write_to, |
| 32 | 33 | uint32_t range_min, uint32_t range_max) |
| @@ -84,7 +85,9 @@ static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc, · 51 unmodified lines | ||
| 84 | 85 | *write_to = value; |
| 85 | 86 | return 0; |
| 86 | 87 | } |
| 88 | +#endif | |
| 87 | 89 | |
| 90 | +#if CBS_WRITE | |
| 88 | 91 | static int cbs_av1_write_uvlc(CodedBitstreamContext *ctx, PutBitContext *pbc, |
| 89 | 92 | const char *name, uint32_t value, |
| 90 | 93 | uint32_t range_min, uint32_t range_max) |
| @@ -115,7 +118,9 @@ static int cbs_av1_write_uvlc(CodedBitstreamContext *ctx, PutBitContext *pbc, · 24 unmodified lines | ||
| 115 | 118 | |
| 116 | 119 | return 0; |
| 117 | 120 | } |
| 121 | +#endif | |
| 118 | 122 | |
| 123 | +#if CBS_READ | |
| 119 | 124 | static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc, |
| 120 | 125 | const char *name, uint64_t *write_to) |
| 121 | 126 | { |
| @@ -146,7 +151,9 @@ static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc, · 24 unmodified lines | ||
| 146 | 151 | *write_to = value; |
| 147 | 152 | return 0; |
| 148 | 153 | } |
| 154 | +#endif | |
| 149 | 155 | |
| 156 | +#if CBS_WRITE | |
| 150 | 157 | static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc, |
| 151 | 158 | const char *name, uint64_t value, int fixed_length) |
| 152 | 159 | { |
| @@ -182,7 +189,9 @@ static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc, · 29 unmodified lines | ||
| 182 | 189 | |
| 183 | 190 | return 0; |
| 184 | 191 | } |
| 192 | +#endif | |
| 185 | 193 | |
| 194 | +#if CBS_READ | |
| 186 | 195 | static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc, |
| 187 | 196 | uint32_t n, const char *name, |
| 188 | 197 | const int *subscripts, uint32_t *write_to) |
| @@ -220,7 +229,9 @@ static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc, · 31 unmodified lines | ||
| 220 | 229 | *write_to = value; |
| 221 | 230 | return 0; |
| 222 | 231 | } |
| 232 | +#endif | |
| 223 | 233 | |
| 234 | +#if CBS_WRITE | |
| 224 | 235 | static int cbs_av1_write_ns(CodedBitstreamContext *ctx, PutBitContext *pbc, |
| 225 | 236 | uint32_t n, const char *name, |
| 226 | 237 | const int *subscripts, uint32_t value) |
| @@ -256,7 +267,9 @@ static int cbs_av1_write_ns(CodedBitstreamContext *ctx, PutBitContext *pbc, · 29 unmodified lines | ||
| 256 | 267 | |
| 257 | 268 | return 0; |
| 258 | 269 | } |
| 270 | +#endif | |
| 259 | 271 | |
| 272 | +#if CBS_READ | |
| 260 | 273 | static int cbs_av1_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc, |
| 261 | 274 | uint32_t range_min, uint32_t range_max, |
| 262 | 275 | const char *name, uint32_t *write_to) |
| @@ -284,7 +297,9 @@ static int cbs_av1_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc · 21 unmodified lines | ||
| 284 | 297 | *write_to = value; |
| 285 | 298 | return 0; |
| 286 | 299 | } |
| 300 | +#endif | |
| 287 | 301 | |
| 302 | +#if CBS_WRITE | |
| 288 | 303 | static int cbs_av1_write_increment(CodedBitstreamContext *ctx, PutBitContext *pbc, |
| 289 | 304 | uint32_t range_min, uint32_t range_max, |
| 290 | 305 | const char *name, uint32_t value) |
| @@ -315,7 +330,9 @@ static int cbs_av1_write_increment(CodedBitstreamContext *ctx, PutBitContext *pb · 24 unmodified lines | ||
| 315 | 330 | |
| 316 | 331 | return 0; |
| 317 | 332 | } |
| 333 | +#endif | |
| 318 | 334 | |
| 335 | +#if CBS_READ | |
| 319 | 336 | static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc, |
| 320 | 337 | uint32_t range_max, const char *name, |
| 321 | 338 | const int *subscripts, uint32_t *write_to) |
| @@ -342,7 +359,7 @@ static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc, · 20 unmodified lines | ||
| 342 | 359 | } |
| 343 | 360 | |
| 344 | 361 | if (len < max_len) { |
| 345 | − err = ff_cbs_read_simple_unsigned(ctx, gbc, range_bits, | |
| 362 | + err = CBS_FUNC(read_simple_unsigned)(ctx, gbc, range_bits, | |
| 346 | 363 | "subexp_bits", &value); |
| 347 | 364 | if (err < 0) |
| 348 | 365 | return err; |
| @@ -360,7 +377,9 @@ static int cbs_av1_read_subexp(CodedBitstreamContext *ctx, GetBitContext *gbc, · 11 unmodified lines | ||
| 360 | 377 | *write_to = value; |
| 361 | 378 | return err; |
| 362 | 379 | } |
| 380 | +#endif | |
| 363 | 381 | |
| 382 | +#if CBS_WRITE | |
| 364 | 383 | static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc, |
| 365 | 384 | uint32_t range_max, const char *name, |
| 366 | 385 | const int *subscripts, uint32_t value) |
| @@ -402,7 +421,7 @@ static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc, · 35 unmodified lines | ||
| 402 | 421 | return err; |
| 403 | 422 | |
| 404 | 423 | if (len < max_len) { |
| 405 | − err = ff_cbs_write_simple_unsigned(ctx, pbc, range_bits, | |
| 424 | + err = CBS_FUNC(write_simple_unsigned)(ctx, pbc, range_bits, | |
| 406 | 425 | "subexp_bits", |
| 407 | 426 | value - range_offset); |
| 408 | 427 | if (err < 0) |
| @@ -420,6 +439,7 @@ static int cbs_av1_write_subexp(CodedBitstreamContext *ctx, PutBitContext *pbc, · 11 unmodified lines | ||
| 420 | 439 | |
| 421 | 440 | return err; |
| 422 | 441 | } |
| 442 | +#endif | |
| 423 | 443 | |
| 424 | 444 | |
| 425 | 445 | static int cbs_av1_tile_log2(int blksize, int target) |
| @@ -441,7 +461,7 @@ static int cbs_av1_get_relative_dist(const AV1RawSequenceHeader *seq, · 15 unmodified lines | ||
| 441 | 461 | return diff; |
| 442 | 462 | } |
| 443 | 463 | |
| 444 | −static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) | |
| 464 | +static av_unused size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) | |
| 445 | 465 | { |
| 446 | 466 | GetBitContext tmp = *gbc; |
| 447 | 467 | size_t size = 0; |
| @@ -454,7 +474,7 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 6 unmodified lines | ||
| 454 | 474 | |
| 455 | 475 | |
| 456 | 476 | #define HEADER(name) do { \ |
| 457 | − ff_cbs_trace_header(ctx, name); \ | |
| 477 | + CBS_FUNC(trace_header)(ctx, name); \ | |
| 458 | 478 | } while (0) |
| 459 | 479 | |
| 460 | 480 | #define CHECK(call) do { \ |
| @@ -469,6 +489,7 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 8 unmodified lines | ||
| 469 | 489 | |
| 470 | 490 | #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) |
| 471 | 491 | |
| 492 | +#if CBS_READ | |
| 472 | 493 | #define fc(width, name, range_min, range_max) \ |
| 473 | 494 | xf(width, name, current->name, range_min, range_max, 0, ) |
| 474 | 495 | #define flag(name) fb(1, name) |
| @@ -496,14 +517,14 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 21 unmodified lines | ||
| 496 | 517 | |
| 497 | 518 | #define fb(width, name) do { \ |
| 498 | 519 | uint32_t value; \ |
| 499 | − CHECK(ff_cbs_read_simple_unsigned(ctx, rw, width, \ | |
| 520 | + CHECK(CBS_FUNC(read_simple_unsigned)(ctx, rw, width, \ | |
| 500 | 521 | #name, &value)); \ |
| 501 | 522 | current->name = value; \ |
| 502 | 523 | } while (0) |
| 503 | 524 | |
| 504 | 525 | #define xf(width, name, var, range_min, range_max, subs, ...) do { \ |
| 505 | 526 | uint32_t value; \ |
| 506 | − CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \ | |
| 527 | + CHECK(CBS_FUNC(read_unsigned)(ctx, rw, width, #name, \ | |
| 507 | 528 | SUBSCRIPTS(subs, __VA_ARGS__), \ |
| 508 | 529 | &value, range_min, range_max)); \ |
| 509 | 530 | var = value; \ |
| @@ -511,7 +532,7 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 1 unmodified line | ||
| 511 | 532 | |
| 512 | 533 | #define xsu(width, name, var, subs, ...) do { \ |
| 513 | 534 | int32_t value; \ |
| 514 | − CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \ | |
| 535 | + CHECK(CBS_FUNC(read_signed)(ctx, rw, width, #name, \ | |
| 515 | 536 | SUBSCRIPTS(subs, __VA_ARGS__), &value, \ |
| 516 | 537 | MIN_INT_BITS(width), \ |
| 517 | 538 | MAX_INT_BITS(width))); \ |
| @@ -584,25 +605,27 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 66 unmodified lines | ||
| 584 | 605 | #undef leb128 |
| 585 | 606 | #undef infer |
| 586 | 607 | #undef byte_alignment |
| 608 | +#endif // CBS_READ | |
| 587 | 609 | |
| 588 | 610 | |
| 611 | +#if CBS_WRITE | |
| 589 | 612 | #define WRITE |
| 590 | 613 | #define READWRITE write |
| 591 | 614 | #define RWContext PutBitContext |
| 592 | 615 | |
| 593 | 616 | #define fb(width, name) do { \ |
| 594 | − CHECK(ff_cbs_write_simple_unsigned(ctx, rw, width, #name, \ | |
| 617 | + CHECK(CBS_FUNC(write_simple_unsigned)(ctx, rw, width, #name, \ | |
| 595 | 618 | current->name)); \ |
| 596 | 619 | } while (0) |
| 597 | 620 | |
| 598 | 621 | #define xf(width, name, var, range_min, range_max, subs, ...) do { \ |
| 599 | − CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \ | |
| 622 | + CHECK(CBS_FUNC(write_unsigned)(ctx, rw, width, #name, \ | |
| 600 | 623 | SUBSCRIPTS(subs, __VA_ARGS__), \ |
| 601 | 624 | var, range_min, range_max)); \ |
| 602 | 625 | } while (0) |
| 603 | 626 | |
| 604 | 627 | #define xsu(width, name, var, subs, ...) do { \ |
| 605 | − CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \ | |
| 628 | + CHECK(CBS_FUNC(write_signed)(ctx, rw, width, #name, \ | |
| 606 | 629 | SUBSCRIPTS(subs, __VA_ARGS__), var, \ |
| 607 | 630 | MIN_INT_BITS(width), \ |
| 608 | 631 | MAX_INT_BITS(width))); \ |
| @@ -668,12 +691,13 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc) · 59 unmodified lines | ||
| 668 | 691 | #undef leb128 |
| 669 | 692 | #undef infer |
| 670 | 693 | #undef byte_alignment |
| 671 | − | |
| 694 | +#endif // CBS_WRITE | |
| 672 | 695 | |
| 673 | 696 | static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, |
| 674 | 697 | CodedBitstreamFragment *frag, |
| 675 | 698 | int header) |
| 676 | 699 | { |
| 700 | +#if CBS_READ | |
| 677 | 701 | GetBitContext gbc; |
| 678 | 702 | uint8_t *data; |
| 679 | 703 | size_t size; |
| @@ -763,7 +787,7 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, · 83 unmodified lines | ||
| 763 | 787 | goto fail; |
| 764 | 788 | } |
| 765 | 789 | |
| 766 | − err = ff_cbs_append_unit_data(frag, obu_header.obu_type, | |
| 790 | + err = CBS_FUNC(append_unit_data)(frag, obu_header.obu_type, | |
| 767 | 791 | data, obu_length, frag->data_ref); |
| 768 | 792 | if (err < 0) |
| 769 | 793 | goto fail; |
| @@ -777,8 +801,12 @@ success: · 7 unmodified lines | ||
| 777 | 801 | fail: |
| 778 | 802 | ctx->trace_enable = trace; |
| 779 | 803 | return err; |
| 804 | +#else | |
| 805 | + return AVERROR(ENOSYS); | |
| 806 | +#endif | |
| 780 | 807 | } |
| 781 | 808 | |
| 809 | +#if CBS_READ | |
| 782 | 810 | static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx, |
| 783 | 811 | CodedBitstreamUnit *unit, |
| 784 | 812 | GetBitContext *gbc, |
| @@ -805,16 +833,18 @@ static int cbs_av1_ref_tile_data(CodedBitstreamContext *ctx, · 20 unmodified lines | ||
| 805 | 833 | |
| 806 | 834 | return 0; |
| 807 | 835 | } |
| 836 | +#endif | |
| 808 | 837 | |
| 809 | 838 | static int cbs_av1_read_unit(CodedBitstreamContext *ctx, |
| 810 | 839 | CodedBitstreamUnit *unit) |
| 811 | 840 | { |
| 841 | +#if CBS_READ | |
| 812 | 842 | CodedBitstreamAV1Context *priv = ctx->priv_data; |
| 813 | 843 | AV1RawOBU *obu; |
| 814 | 844 | GetBitContext gbc; |
| 815 | 845 | int err, start_pos, end_pos; |
| 816 | 846 | |
| 817 | − err = ff_cbs_alloc_unit_content(ctx, unit); | |
| 847 | + err = CBS_FUNC(alloc_unit_content)(ctx, unit); | |
| 818 | 848 | if (err < 0) |
| 819 | 849 | return err; |
| 820 | 850 | obu = unit->content; |
| @@ -931,6 +961,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 110 unmodified lines | ||
| 931 | 961 | return err; |
| 932 | 962 | } |
| 933 | 963 | break; |
| 964 | +#if CBS_AV1_OBU_TILE_LIST | |
| 934 | 965 | case AV1_OBU_TILE_LIST: |
| 935 | 966 | { |
| 936 | 967 | err = cbs_av1_read_tile_list_obu(ctx, &gbc, |
| @@ -946,6 +977,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 9 unmodified lines | ||
| 946 | 977 | return err; |
| 947 | 978 | } |
| 948 | 979 | break; |
| 980 | +#endif | |
| 981 | +#if CBS_AV1_OBU_METADATA | |
| 949 | 982 | case AV1_OBU_METADATA: |
| 950 | 983 | { |
| 951 | 984 | err = cbs_av1_read_metadata_obu(ctx, &gbc, &obu->obu.metadata); |
| @@ -953,6 +986,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 1 unmodified line | ||
| 953 | 986 | return err; |
| 954 | 987 | } |
| 955 | 988 | break; |
| 989 | +#endif | |
| 990 | +#if CBS_AV1_OBU_PADDING | |
| 956 | 991 | case AV1_OBU_PADDING: |
| 957 | 992 | { |
| 958 | 993 | err = cbs_av1_read_padding_obu(ctx, &gbc, &obu->obu.padding); |
| @@ -960,6 +995,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 1 unmodified line | ||
| 960 | 995 | return err; |
| 961 | 996 | } |
| 962 | 997 | break; |
| 998 | +#endif | |
| 963 | 999 | default: |
| 964 | 1000 | return AVERROR(ENOSYS); |
| 965 | 1001 | } |
| @@ -982,12 +1018,16 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, · 16 unmodified lines | ||
| 982 | 1018 | } |
| 983 | 1019 | |
| 984 | 1020 | return 0; |
| 1021 | +#else | |
| 1022 | + return AVERROR(ENOSYS); | |
| 1023 | +#endif | |
| 985 | 1024 | } |
| 986 | 1025 | |
| 987 | 1026 | static int cbs_av1_write_obu(CodedBitstreamContext *ctx, |
| 988 | 1027 | CodedBitstreamUnit *unit, |
| 989 | 1028 | PutBitContext *pbc) |
| 990 | 1029 | { |
| 1030 | +#if CBS_WRITE | |
| 991 | 1031 | CodedBitstreamAV1Context *priv = ctx->priv_data; |
| 992 | 1032 | AV1RawOBU *obu = unit->content; |
| 993 | 1033 | PutBitContext pbc_tmp; |
| @@ -1044,7 +1084,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 50 unmodified lines | ||
| 1044 | 1084 | av_refstruct_unref(&priv->sequence_header_ref); |
| 1045 | 1085 | priv->sequence_header = NULL; |
| 1046 | 1086 | |
| 1047 | − err = ff_cbs_make_unit_refcounted(ctx, unit); | |
| 1087 | + err = CBS_FUNC(make_unit_refcounted)(ctx, unit); | |
| 1048 | 1088 | if (err < 0) |
| 1049 | 1089 | goto error; |
| 1050 | 1090 | |
| @@ -1087,6 +1127,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 36 unmodified lines | ||
| 1087 | 1127 | td = &tile_group->tile_data; |
| 1088 | 1128 | } |
| 1089 | 1129 | break; |
| 1130 | +#if CBS_AV1_OBU_TILE_LIST | |
| 1090 | 1131 | case AV1_OBU_TILE_LIST: |
| 1091 | 1132 | { |
| 1092 | 1133 | err = cbs_av1_write_tile_list_obu(ctx, pbc, &obu->obu.tile_list); |
| @@ -1096,6 +1137,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 3 unmodified lines | ||
| 1096 | 1137 | td = &obu->obu.tile_list.tile_data; |
| 1097 | 1138 | } |
| 1098 | 1139 | break; |
| 1140 | +#endif | |
| 1141 | +#if CBS_AV1_OBU_METADATA | |
| 1099 | 1142 | case AV1_OBU_METADATA: |
| 1100 | 1143 | { |
| 1101 | 1144 | err = cbs_av1_write_metadata_obu(ctx, pbc, &obu->obu.metadata); |
| @@ -1103,6 +1146,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 1 unmodified line | ||
| 1103 | 1146 | goto error; |
| 1104 | 1147 | } |
| 1105 | 1148 | break; |
| 1149 | +#endif | |
| 1150 | +#if CBS_AV1_OBU_PADDING | |
| 1106 | 1151 | case AV1_OBU_PADDING: |
| 1107 | 1152 | { |
| 1108 | 1153 | err = cbs_av1_write_padding_obu(ctx, pbc, &obu->obu.padding); |
| @@ -1110,6 +1155,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, · 1 unmodified line | ||
| 1110 | 1155 | goto error; |
| 1111 | 1156 | } |
| 1112 | 1157 | break; |
| 1158 | +#endif | |
| 1113 | 1159 | default: |
| 1114 | 1160 | err = AVERROR(ENOSYS); |
| 1115 | 1161 | goto error; |
| @@ -1182,11 +1228,15 @@ error: · 66 unmodified lines | ||
| 1182 | 1228 | av_buffer_unref(&av1ctx.frame_header_ref); |
| 1183 | 1229 | |
| 1184 | 1230 | return err; |
| 1231 | +#else | |
| 1232 | + return AVERROR(ENOSYS); | |
| 1233 | +#endif | |
| 1185 | 1234 | } |
| 1186 | 1235 | |
| 1187 | 1236 | static int cbs_av1_assemble_fragment(CodedBitstreamContext *ctx, |
| 1188 | 1237 | CodedBitstreamFragment *frag) |
| 1189 | 1238 | { |
| 1239 | +#if CBS_WRITE | |
| 1190 | 1240 | size_t size, pos; |
| 1191 | 1241 | int i; |
| 1192 | 1242 | |
| @@ -1210,6 +1260,9 @@ static int cbs_av1_assemble_fragment(CodedBitstreamContext *ctx, · 17 unmodified lines | ||
| 1210 | 1260 | frag->data_size = size; |
| 1211 | 1261 | |
| 1212 | 1262 | return 0; |
| 1263 | +#else | |
| 1264 | + return AVERROR(ENOSYS); | |
| 1265 | +#endif | |
| 1213 | 1266 | } |
| 1214 | 1267 | |
| 1215 | 1268 | static void cbs_av1_flush(CodedBitstreamContext *ctx) |
| @@ -1234,6 +1287,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx) · 18 unmodified lines | ||
| 1234 | 1287 | av_buffer_unref(&priv->frame_header_ref); |
| 1235 | 1288 | } |
| 1236 | 1289 | |
| 1290 | +#if CBS_AV1_OBU_METADATA | |
| 1237 | 1291 | static void cbs_av1_free_metadata(AVRefStructOpaque unused, void *content) |
| 1238 | 1292 | { |
| 1239 | 1293 | AV1RawOBU *obu = content; |
| @@ -1255,6 +1309,7 @@ static void cbs_av1_free_metadata(AVRefStructOpaque unused, void *content) · 15 unmodified lines | ||
| 1255 | 1309 | av_buffer_unref(&md->metadata.unknown.payload_ref); |
| 1256 | 1310 | } |
| 1257 | 1311 | } |
| 1312 | +#endif | |
| 1258 | 1313 | |
| 1259 | 1314 | static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = { |
| 1260 | 1315 | CBS_UNIT_TYPE_POD(AV1_OBU_SEQUENCE_HEADER, AV1RawOBU), |
| @@ -1284,13 +1339,19 @@ static const CodedBitstreamUnitTypeDescriptor cbs_av1_unit_types[] = { · 23 unmodified lines | ||
| 1284 | 1339 | offsetof(AV1RawOBU, obu.frame.tile_group.tile_data.data) } |
| 1285 | 1340 | }, |
| 1286 | 1341 | }, |
| 1342 | +#if CBS_AV1_OBU_TILE_LIST | |
| 1287 | 1343 | CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_TILE_LIST, AV1RawOBU, |
| 1288 | 1344 | obu.tile_list.tile_data.data), |
| 1345 | +#endif | |
| 1346 | +#if CBS_AV1_OBU_PADDING | |
| 1289 | 1347 | CBS_UNIT_TYPE_INTERNAL_REF(AV1_OBU_PADDING, AV1RawOBU, |
| 1290 | 1348 | obu.padding.payload), |
| 1349 | +#endif | |
| 1291 | 1350 | |
| 1351 | +#if CBS_AV1_OBU_METADATA | |
| 1292 | 1352 | CBS_UNIT_TYPE_COMPLEX(AV1_OBU_METADATA, AV1RawOBU, |
| 1293 | 1353 | &cbs_av1_free_metadata), |
| 1354 | +#endif | |
| 1294 | 1355 | |
| 1295 | 1356 | CBS_UNIT_TYPE_END_OF_LIST |
| 1296 | 1357 | }; |
| @@ -1311,7 +1372,7 @@ static const AVClass cbs_av1_class = { · 14 unmodified lines | ||
| 1311 | 1372 | .version = LIBAVUTIL_VERSION_INT, |
| 1312 | 1373 | }; |
| 1313 | 1374 | |
| 1314 | −const CodedBitstreamType ff_cbs_type_av1 = { | |
| 1375 | +const CodedBitstreamType CBS_FUNC(type_av1) = { | |
| 1315 | 1376 | .codec_id = AV_CODEC_ID_AV1, |
| 1316 | 1377 | |
| 1317 | 1378 | .priv_class = &cbs_av1_class, |
| @@ -25,6 +25,15 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "av1.h" |
| 26 | 26 | #include "cbs.h" |
| 27 | 27 | |
| 28 | +#ifndef CBS_AV1_OBU_METADATA | |
| 29 | +#define CBS_AV1_OBU_METADATA 1 | |
| 30 | +#endif | |
| 31 | +#ifndef CBS_AV1_OBU_TILE_LIST | |
| 32 | +#define CBS_AV1_OBU_TILE_LIST 1 | |
| 33 | +#endif | |
| 34 | +#ifndef CBS_AV1_OBU_PADDING | |
| 35 | +#define CBS_AV1_OBU_PADDING 1 | |
| 36 | +#endif | |
| 28 | 37 | |
| 29 | 38 | typedef struct AV1RawOBUHeader { |
| 30 | 39 | uint8_t obu_forbidden_bit; |
| @@ -411,9 +420,15 @@ typedef struct AV1RawOBU { · 380 unmodified lines | ||
| 411 | 420 | AV1RawFrameHeader frame_header; |
| 412 | 421 | AV1RawFrame frame; |
| 413 | 422 | AV1RawTileGroup tile_group; |
| 423 | +#if CBS_AV1_OBU_TILE_LIST | |
| 414 | 424 | AV1RawTileList tile_list; |
| 425 | +#endif | |
| 426 | +#if CBS_AV1_OBU_METADATA | |
| 415 | 427 | AV1RawMetadata metadata; |
| 428 | +#endif | |
| 429 | +#if CBS_AV1_OBU_PADDING | |
| 416 | 430 | AV1RawPadding padding; |
| 431 | +#endif | |
| 417 | 432 | } obu; |
| 418 | 433 | } AV1RawOBU; |
| 419 | 434 | |
| @@ -1868,6 +1868,7 @@ static int FUNC(frame_obu)(CodedBitstreamContext *ctx, RWContext *rw, · 1867 unmodified lines | ||
| 1868 | 1868 | return 0; |
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | +#if CBS_AV1_OBU_TILE_LIST | |
| 1871 | 1872 | static int FUNC(tile_list_obu)(CodedBitstreamContext *ctx, RWContext *rw, |
| 1872 | 1873 | AV1RawTileList *current) |
| 1873 | 1874 | { |
| @@ -1882,7 +1883,9 @@ static int FUNC(tile_list_obu)(CodedBitstreamContext *ctx, RWContext *rw, · 8 unmodified lines | ||
| 1882 | 1883 | |
| 1883 | 1884 | return 0; |
| 1884 | 1885 | } |
| 1886 | +#endif | |
| 1885 | 1887 | |
| 1888 | +#if CBS_AV1_OBU_METADATA | |
| 1886 | 1889 | static int FUNC(metadata_hdr_cll)(CodedBitstreamContext *ctx, RWContext *rw, |
| 1887 | 1890 | AV1RawMetadataHDRCLL *current) |
| 1888 | 1891 | { |
| @@ -2101,7 +2104,9 @@ static int FUNC(metadata_obu)(CodedBitstreamContext *ctx, RWContext *rw, · 212 unmodified lines | ||
| 2101 | 2104 | |
| 2102 | 2105 | return 0; |
| 2103 | 2106 | } |
| 2107 | +#endif | |
| 2104 | 2108 | |
| 2109 | +#if CBS_AV1_OBU_PADDING | |
| 2105 | 2110 | static int FUNC(padding_obu)(CodedBitstreamContext *ctx, RWContext *rw, |
| 2106 | 2111 | AV1RawPadding *current) |
| 2107 | 2112 | { |
| @@ -2125,3 +2130,4 @@ static int FUNC(padding_obu)(CodedBitstreamContext *ctx, RWContext *rw, · 17 unmodified lines | ||
| 2125 | 2130 | |
| 2126 | 2131 | return 0; |
| 2127 | 2132 | } |
| 2133 | +#endif | |
| @@ -22,6 +22,8 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <stddef.h> |
| 23 | 23 | #include <stdint.h> |
| 24 | 24 | |
| 25 | +#include "config.h" | |
| 26 | + | |
| 25 | 27 | #include "libavutil/log.h" |
| 26 | 28 | |
| 27 | 29 | #include "cbs.h" |
| @@ -30,6 +32,40 @@ · 2 unmodified lines | ||
| 30 | 32 | #include "put_bits.h" |
| 31 | 33 | #include "libavutil/refstruct.h" |
| 32 | 34 | |
| 35 | +#ifndef CBS_READ | |
| 36 | +#define CBS_READ 1 | |
| 37 | +#endif | |
| 38 | +#ifndef CBS_WRITE | |
| 39 | +#define CBS_WRITE 1 | |
| 40 | +#endif | |
| 41 | +#ifndef CBS_TRACE | |
| 42 | +#define CBS_TRACE 1 | |
| 43 | +#endif | |
| 44 | + | |
| 45 | +#ifndef CBS_AV1 | |
| 46 | +#define CBS_AV1 CONFIG_CBS_AV1 | |
| 47 | +#endif | |
| 48 | +#ifndef CBS_H264 | |
| 49 | +#define CBS_H264 CONFIG_CBS_H264 | |
| 50 | +#endif | |
| 51 | +#ifndef CBS_H265 | |
| 52 | +#define CBS_H265 CONFIG_CBS_H265 | |
| 53 | +#endif | |
| 54 | +#ifndef CBS_H266 | |
| 55 | +#define CBS_H266 CONFIG_CBS_H266 | |
| 56 | +#endif | |
| 57 | +#ifndef CBS_JPEG | |
| 58 | +#define CBS_JPEG CONFIG_CBS_JPEG | |
| 59 | +#endif | |
| 60 | +#ifndef CBS_MPEG2 | |
| 61 | +#define CBS_MPEG2 CONFIG_CBS_MPEG2 | |
| 62 | +#endif | |
| 63 | +#ifndef CBS_VP8 | |
| 64 | +#define CBS_VP8 CONFIG_CBS_VP8 | |
| 65 | +#endif | |
| 66 | +#ifndef CBS_VP9 | |
| 67 | +#define CBS_VP9 CONFIG_CBS_VP9 | |
| 68 | +#endif | |
| 33 | 69 | |
| 34 | 70 | enum CBSContentType { |
| 35 | 71 | // Unit content may contain some references to other structures, but all |
| @@ -155,7 +191,7 @@ typedef struct CodedBitstreamType { · 119 unmodified lines | ||
| 155 | 191 | |
| 156 | 192 | // Helper functions for trace output. |
| 157 | 193 | |
| 158 | −void ff_cbs_trace_header(CodedBitstreamContext *ctx, | |
| 194 | +void CBS_FUNC(trace_header)(CodedBitstreamContext *ctx, | |
| 159 | 195 | const char *name); |
| 160 | 196 | |
| 161 | 197 | |
| @@ -165,28 +201,28 @@ void ff_cbs_trace_header(CodedBitstreamContext *ctx, · 3 unmodified lines | ||
| 165 | 201 | // (i.e. only limited by the amount of bits used) and they lack |
| 166 | 202 | // the ability to use subscripts. |
| 167 | 203 | |
| 168 | −int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 204 | +int CBS_FUNC(read_unsigned)(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 169 | 205 | int width, const char *name, |
| 170 | 206 | const int *subscripts, uint32_t *write_to, |
| 171 | 207 | uint32_t range_min, uint32_t range_max); |
| 172 | 208 | |
| 173 | −int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 209 | +int CBS_FUNC(read_simple_unsigned)(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 174 | 210 | int width, const char *name, uint32_t *write_to); |
| 175 | 211 | |
| 176 | −int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 212 | +int CBS_FUNC(write_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 177 | 213 | int width, const char *name, |
| 178 | 214 | const int *subscripts, uint32_t value, |
| 179 | 215 | uint32_t range_min, uint32_t range_max); |
| 180 | 216 | |
| 181 | −int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 217 | +int CBS_FUNC(write_simple_unsigned)(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 182 | 218 | int width, const char *name, uint32_t value); |
| 183 | 219 | |
| 184 | −int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 220 | +int CBS_FUNC(read_signed)(CodedBitstreamContext *ctx, GetBitContext *gbc, | |
| 185 | 221 | int width, const char *name, |
| 186 | 222 | const int *subscripts, int32_t *write_to, |
| 187 | 223 | int32_t range_min, int32_t range_max); |
| 188 | 224 | |
| 189 | −int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 225 | +int CBS_FUNC(write_signed)(CodedBitstreamContext *ctx, PutBitContext *pbc, | |
| 190 | 226 | int width, const char *name, |
| 191 | 227 | const int *subscripts, int32_t value, |
| 192 | 228 | int32_t range_min, int32_t range_max); |
| @@ -204,6 +240,7 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, · 11 unmodified lines | ||
| 204 | 240 | #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1))) |
| 205 | 241 | |
| 206 | 242 | |
| 243 | +#if CBS_TRACE | |
| 207 | 244 | // Start of a syntax element during read tracing. |
| 208 | 245 | #define CBS_TRACE_READ_START() \ |
| 209 | 246 | GetBitContext trace_start; \ |
| @@ -284,6 +321,17 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, · 74 unmodified lines | ||
| 284 | 321 | } \ |
| 285 | 322 | } while (0) |
| 286 | 323 | |
| 324 | +#else // CBS_TRACE | |
| 325 | +#define CBS_TRACE_READ_START() do { } while (0) | |
| 326 | +#define CBS_TRACE_READ_END() do { } while (0) | |
| 327 | +#define CBS_TRACE_READ_END_NO_SUBSCRIPTS() do { } while (0) | |
| 328 | +#define CBS_TRACE_READ_END_VALUE_ONLY() do { } while (0) | |
| 329 | +#define CBS_TRACE_WRITE_START() do { } while (0) | |
| 330 | +#define CBS_TRACE_WRITE_END() do { } while (0) | |
| 331 | +#define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() do { } while (0) | |
| 332 | +#define CBS_TRACE_WRITE_END_VALUE_ONLY() do { } while (0) | |
| 333 | +#endif // CBS_TRACE | |
| 334 | + | |
| 287 | 335 | #define TYPE_LIST(...) { __VA_ARGS__ } |
| 288 | 336 | #define CBS_UNIT_TYPE_POD(type_, structure) { \ |
| 289 | 337 | .nb_unit_types = 1, \ |
| @@ -335,14 +383,14 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, · 45 unmodified lines | ||
| 335 | 383 | #define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 } |
| 336 | 384 | |
| 337 | 385 | |
| 338 | −extern const CodedBitstreamType ff_cbs_type_av1; | |
| 339 | −extern const CodedBitstreamType ff_cbs_type_h264; | |
| 340 | −extern const CodedBitstreamType ff_cbs_type_h265; | |
| 341 | −extern const CodedBitstreamType ff_cbs_type_h266; | |
| 342 | −extern const CodedBitstreamType ff_cbs_type_jpeg; | |
| 343 | −extern const CodedBitstreamType ff_cbs_type_mpeg2; | |
| 344 | −extern const CodedBitstreamType ff_cbs_type_vp8; | |
| 345 | −extern const CodedBitstreamType ff_cbs_type_vp9; | |
| 386 | +extern const CodedBitstreamType CBS_FUNC(type_av1); | |
| 387 | +extern const CodedBitstreamType CBS_FUNC(type_h264); | |
| 388 | +extern const CodedBitstreamType CBS_FUNC(type_h265); | |
| 389 | +extern const CodedBitstreamType CBS_FUNC(type_h266); | |
| 390 | +extern const CodedBitstreamType CBS_FUNC(type_jpeg); | |
| 391 | +extern const CodedBitstreamType CBS_FUNC(type_mpeg2); | |
| 392 | +extern const CodedBitstreamType CBS_FUNC(type_vp8); | |
| 393 | +extern const CodedBitstreamType CBS_FUNC(type_vp9); | |
| 346 | 394 | |
| 347 | 395 | |
| 348 | 396 | #endif /* AVCODEC_CBS_INTERNAL_H */ |