Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -20,6 +20,8 @@ · 19 unmodified lines | |||
| 20 | * License along with FFmpeg; if not, write to the Free Software | 20 | * License along with FFmpeg; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 | */ | 22 | */ |
| 23 | |||
| 24 | #include "libavcodec/bytestream.h" | ||
| 23 | #include "libavcodec/codec_internal.h" | 25 | #include "libavcodec/codec_internal.h" |
| 24 | #include "libavcodec/decode.h" | 26 | #include "libavcodec/decode.h" |
| 25 | #include "libavcodec/hwaccel_internal.h" | 27 | #include "libavcodec/hwaccel_internal.h" |
| @@ -509,13 +511,14 @@ static int slices_realloc(VVCFrameContext *fc) · 483 unmodified lines | |||
| 509 | return 0; | 511 | return 0; |
| 510 | } | 512 | } |
| 511 | 513 | ||
| 512 | static int get_ep_size(const H266RawSliceHeader *rsh, GetBitContext *gb, const H2645NAL *nal, const int header_size, const int ep_index) | 514 | static int get_ep_size(const H266RawSliceHeader *rsh, const GetByteContext *gb, |
| 515 | const H2645NAL *nal, const int header_size, const int ep_index) | ||
| 513 | { | 516 | { |
| 514 | int size; | 517 | int size; |
| 515 | 518 | ||
| 516 | if (ep_index < rsh->num_entry_points) { | 519 | if (ep_index < rsh->num_entry_points) { |
| 517 | int skipped = 0; | 520 | int skipped = 0; |
| 518 | int64_t start = (gb->index >> 3); | 521 | int64_t start = bytestream2_tell(gb); |
| 519 | int64_t end = start + rsh->sh_entry_point_offset_minus1[ep_index] + 1; | 522 | int64_t end = start + rsh->sh_entry_point_offset_minus1[ep_index] + 1; |
| 520 | while (skipped < nal->skipped_bytes && nal->skipped_bytes_pos[skipped] <= start + header_size) { | 523 | while (skipped < nal->skipped_bytes && nal->skipped_bytes_pos[skipped] <= start + header_size) { |
| 521 | skipped++; | 524 | skipped++; |
| @@ -525,26 +528,27 @@ static int get_ep_size(const H266RawSliceHeader *rsh, GetBitContext *gb, const H · 3 unmodified lines | |||
| 525 | skipped++; | 528 | skipped++; |
| 526 | } | 529 | } |
| 527 | size = end - start; | 530 | size = end - start; |
| 528 | size = av_clip(size, 0, get_bits_left(gb) / 8); | 531 | size = av_clip(size, 0, bytestream2_get_bytes_left(gb)); |
| 529 | } else { | 532 | } else { |
| 530 | size = get_bits_left(gb) / 8; | 533 | size = bytestream2_get_bytes_left(gb); |
| 531 | } | 534 | } |
| 532 | return size; | 535 | return size; |
| 533 | } | 536 | } |
| 534 | 537 | ||
| 535 | static int ep_init_cabac_decoder(EntryPoint *ep, GetBitContext *gb, const int size) | 538 | static int ep_init_cabac_decoder(EntryPoint *ep, GetByteContext *gb, const int size) |
| 536 | { | 539 | { |
| 537 | int ret; | 540 | int ret; |
| 538 | 541 | ||
| 539 | av_assert0(gb->buffer + get_bits_count(gb) / 8 + size <= gb->buffer_end); | 542 | av_assert0(size <= bytestream2_get_bytes_left(gb)); |
| 540 | ret = ff_init_cabac_decoder (&ep->cc, gb->buffer + get_bits_count(gb) / 8, size); | 543 | ret = ff_init_cabac_decoder(&ep->cc, gb->buffer, size); |
| 541 | if (ret < 0) | 544 | if (ret < 0) |
| 542 | return ret; | 545 | return ret; |
| 543 | skip_bits(gb, size * 8); | 546 | bytestream2_skipu(gb, size); |
| 544 | return 0; | 547 | return 0; |
| 545 | } | 548 | } |
| 546 | 549 | ||
| 547 | static int ep_init(EntryPoint *ep, const int ctu_addr, const int ctu_end, GetBitContext *gb, const int size) | 550 | static int ep_init(EntryPoint *ep, const int ctu_addr, const int ctu_end, |
| 551 | GetByteContext *gb, const int size) | ||
| 548 | { | 552 | { |
| 549 | const int ret = ep_init_cabac_decoder(ep, gb, size); | 553 | const int ret = ep_init_cabac_decoder(ep, gb, size); |
| 550 | 554 | ||
| @@ -567,7 +571,7 @@ static int slice_init_entry_points(SliceContext *sc, · 16 unmodified lines | |||
| 567 | const H266RawSlice *slice = unit->content_ref; | 571 | const H266RawSlice *slice = unit->content_ref; |
| 568 | int nb_eps = sh->r->num_entry_points + 1; | 572 | int nb_eps = sh->r->num_entry_points + 1; |
| 569 | int ctu_addr = 0; | 573 | int ctu_addr = 0; |
| 570 | GetBitContext gb; | 574 | GetByteContext gb; |
| 571 | int ret; | 575 | int ret; |
| 572 | 576 | ||
| 573 | if (sc->nb_eps != nb_eps) { | 577 | if (sc->nb_eps != nb_eps) { |
| @@ -578,9 +582,8 @@ static int slice_init_entry_points(SliceContext *sc, · 4 unmodified lines | |||
| 578 | sc->nb_eps = nb_eps; | 582 | sc->nb_eps = nb_eps; |
| 579 | } | 583 | } |
| 580 | 584 | ||
| 581 | ret = init_get_bits8(&gb, slice->data, slice->data_size); | 585 | bytestream2_init(&gb, slice->data, slice->data_size); |
| 582 | if (ret < 0) | 586 | |
| 583 | return ret; | ||
| 584 | for (int i = 0; i < sc->nb_eps; i++) | 587 | for (int i = 0; i < sc->nb_eps; i++) |
| 585 | { | 588 | { |
| 586 | const int size = get_ep_size(sc->sh.r, &gb, nal, slice->header_size, i); | 589 | const int size = get_ep_size(sc->sh.r, &gb, nal, slice->header_size, i); |