| @@ -1612,18 +1612,18 @@ av_cold void ff_init_vlc_rl(RLTable *rl) · 1611 unmodified lines |
| 1612 | 1612 | } |
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | | −static void release_unused_pictures(MpegEncContext *s) |
| 1615 | +static void release_unused_pictures(AVCodecContext *avctx, Picture *picture) |
| 1616 | 1616 | { |
| 1617 | 1617 | int i; |
| 1618 | 1618 | |
| 1619 | 1619 | /* release non reference frames */ |
| 1620 | 1620 | for (i = 0; i < MAX_PICTURE_COUNT; i++) { |
| 1621 | | − if (!s->picture[i].reference) |
| 1622 | | − ff_mpeg_unref_picture(s->avctx, &s->picture[i]); |
| 1621 | + if (!picture[i].reference) |
| 1622 | + ff_mpeg_unref_picture(avctx, &picture[i]); |
| 1623 | 1623 | } |
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | | −static inline int pic_is_unused(MpegEncContext *s, Picture *pic) |
| 1626 | +static inline int pic_is_unused(Picture *pic) |
| 1627 | 1627 | { |
| 1628 | 1628 | if (!pic->f->buf[0]) |
| 1629 | 1629 | return 1; |
| @@ -1632,18 +1632,18 @@ static inline int pic_is_unused(MpegEncContext *s, Picture *pic) · 2 unmodified lines |
| 1632 | 1632 | return 0; |
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | | −static int find_unused_picture(MpegEncContext *s, int shared) |
| 1635 | +static int find_unused_picture(Picture *picture, int shared) |
| 1636 | 1636 | { |
| 1637 | 1637 | int i; |
| 1638 | 1638 | |
| 1639 | 1639 | if (shared) { |
| 1640 | 1640 | for (i = 0; i < MAX_PICTURE_COUNT; i++) { |
| 1641 | | − if (!s->picture[i].f->buf[0]) |
| 1641 | + if (!picture[i].f->buf[0]) |
| 1642 | 1642 | return i; |
| 1643 | 1643 | } |
| 1644 | 1644 | } else { |
| 1645 | 1645 | for (i = 0; i < MAX_PICTURE_COUNT; i++) { |
| 1646 | | − if (pic_is_unused(s, &s->picture[i])) |
| 1646 | + if (pic_is_unused(&picture[i])) |
| 1647 | 1647 | return i; |
| 1648 | 1648 | } |
| 1649 | 1649 | } |
| @@ -1651,15 +1651,15 @@ static int find_unused_picture(MpegEncContext *s, int shared) · 1 unmodified line |
| 1651 | 1651 | return AVERROR_INVALIDDATA; |
| 1652 | 1652 | } |
| 1653 | 1653 | |
| 1654 | | −int ff_find_unused_picture(MpegEncContext *s, int shared) |
| 1654 | +int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared) |
| 1655 | 1655 | { |
| 1656 | | − int ret = find_unused_picture(s, shared); |
| 1656 | + int ret = find_unused_picture(picture, shared); |
| 1657 | 1657 | |
| 1658 | 1658 | if (ret >= 0 && ret < MAX_PICTURE_COUNT) { |
| 1659 | | − if (s->picture[ret].needs_realloc) { |
| 1660 | | − s->picture[ret].needs_realloc = 0; |
| 1661 | | − ff_free_picture_tables(&s->picture[ret]); |
| 1662 | | − ff_mpeg_unref_picture(s->avctx, &s->picture[ret]); |
| 1659 | + if (picture[ret].needs_realloc) { |
| 1660 | + picture[ret].needs_realloc = 0; |
| 1661 | + ff_free_picture_tables(&picture[ret]); |
| 1662 | + ff_mpeg_unref_picture(avctx, &picture[ret]); |
| 1663 | 1663 | } |
| 1664 | 1664 | } |
| 1665 | 1665 | return ret; |
| @@ -1697,14 +1697,14 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 31 unmodified lines |
| 1697 | 1697 | |
| 1698 | 1698 | ff_mpeg_unref_picture(s->avctx, &s->current_picture); |
| 1699 | 1699 | |
| 1700 | | − release_unused_pictures(s); |
| 1700 | + release_unused_pictures(s->avctx, s->picture); |
| 1701 | 1701 | |
| 1702 | 1702 | if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) { |
| 1703 | 1703 | // we already have a unused image |
| 1704 | 1704 | // (maybe it was set before reading the header) |
| 1705 | 1705 | pic = s->current_picture_ptr; |
| 1706 | 1706 | } else { |
| 1707 | | − i = ff_find_unused_picture(s, 0); |
| 1707 | + i = ff_find_unused_picture(s->avctx, s->picture, 0); |
| 1708 | 1708 | if (i < 0) { |
| 1709 | 1709 | av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); |
| 1710 | 1710 | return i; |
| @@ -1771,7 +1771,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 60 unmodified lines |
| 1771 | 1771 | "allocate dummy last picture for field based first keyframe\n"); |
| 1772 | 1772 | |
| 1773 | 1773 | /* Allocate a dummy frame */ |
| 1774 | | − i = ff_find_unused_picture(s, 0); |
| 1774 | + i = ff_find_unused_picture(s->avctx, s->picture, 0); |
| 1775 | 1775 | if (i < 0) { |
| 1776 | 1776 | av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); |
| 1777 | 1777 | return i; |
| @@ -1801,7 +1801,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 23 unmodified lines |
| 1801 | 1801 | if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) && |
| 1802 | 1802 | s->pict_type == AV_PICTURE_TYPE_B) { |
| 1803 | 1803 | /* Allocate a dummy frame */ |
| 1804 | | − i = ff_find_unused_picture(s, 0); |
| 1804 | + i = ff_find_unused_picture(s->avctx, s->picture, 0); |
| 1805 | 1805 | if (i < 0) { |
| 1806 | 1806 | av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n"); |
| 1807 | 1807 | return i; |