This enables returning AVERRORs
Unified · Split
| @@ -129,7 +129,7 @@ typedef struct MXFContainerEssenceEntry { · 128 unmodified lines | ||
| 129 | 129 | UID container_ul; |
| 130 | 130 | UID element_ul; |
| 131 | 131 | UID codec_ul; |
| 132 | − void (*write_desc)(AVFormatContext *, AVStream *); | |
| 132 | + int (*write_desc)(AVFormatContext *, AVStream *); | |
| 133 | 133 | } MXFContainerEssenceEntry; |
| 134 | 134 | |
| 135 | 135 | typedef struct MXFPackage { |
| @@ -170,14 +170,14 @@ static const struct { · 34 unmodified lines | ||
| 170 | 170 | { AV_CODEC_ID_NONE } |
| 171 | 171 | }; |
| 172 | 172 | |
| 173 | −static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st); | |
| 174 | −static void mxf_write_aes3_desc(AVFormatContext *s, AVStream *st); | |
| 175 | −static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st); | |
| 176 | −static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st); | |
| 177 | −static void mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st); | |
| 178 | −static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st); | |
| 179 | −static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st); | |
| 180 | −static void mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st); | |
| 173 | +static int mxf_write_wav_desc(AVFormatContext *s, AVStream *st); | |
| 174 | +static int mxf_write_aes3_desc(AVFormatContext *s, AVStream *st); | |
| 175 | +static int mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st); | |
| 176 | +static int mxf_write_h264_desc(AVFormatContext *s, AVStream *st); | |
| 177 | +static int mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st); | |
| 178 | +static int mxf_write_cdci_desc(AVFormatContext *s, AVStream *st); | |
| 179 | +static int mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st); | |
| 180 | +static int mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st); | |
| 181 | 181 | |
| 182 | 182 | static const MXFContainerEssenceEntry mxf_essence_container_uls[] = { |
| 183 | 183 | { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, |
| @@ -1545,7 +1545,7 @@ static void mxf_write_jpeg2000_subdesc(AVFormatContext *s, AVStream *st) · 1361 unmodified lines | ||
| 1545 | 1545 | mxf_update_klv_size(pb, pos); |
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | −static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st) | |
| 1548 | +static int mxf_write_cdci_desc(AVFormatContext *s, AVStream *st) | |
| 1549 | 1549 | { |
| 1550 | 1550 | int64_t pos = mxf_write_cdci_common(s, st, mxf_cdci_descriptor_key); |
| 1551 | 1551 | mxf_update_klv_size(s->pb, pos); |
| @@ -1556,9 +1556,10 @@ static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st) · 4 unmodified lines | ||
| 1556 | 1556 | if (st->codecpar->codec_id == AV_CODEC_ID_JPEG2000) { |
| 1557 | 1557 | mxf_write_jpeg2000_subdesc(s, st); |
| 1558 | 1558 | } |
| 1559 | + return 0; | |
| 1559 | 1560 | } |
| 1560 | 1561 | |
| 1561 | −static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st) | |
| 1562 | +static int mxf_write_h264_desc(AVFormatContext *s, AVStream *st) | |
| 1562 | 1563 | { |
| 1563 | 1564 | MXFStreamContext *sc = st->priv_data; |
| 1564 | 1565 | if (sc->avc_intra) { |
| @@ -1568,9 +1569,10 @@ static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st) · 3 unmodified lines | ||
| 1568 | 1569 | mxf_update_klv_size(s->pb, pos); |
| 1569 | 1570 | mxf_write_avc_subdesc(s, st); |
| 1570 | 1571 | } |
| 1572 | + return 0; | |
| 1571 | 1573 | } |
| 1572 | 1574 | |
| 1573 | −static void mxf_write_ffv1_subdesc(AVFormatContext *s, AVStream *st) | |
| 1575 | +static int mxf_write_ffv1_subdesc(AVFormatContext *s, AVStream *st) | |
| 1574 | 1576 | { |
| 1575 | 1577 | AVIOContext *pb = s->pb; |
| 1576 | 1578 | MXFStreamContext *sc = st->priv_data; |
| @@ -1597,9 +1599,10 @@ static void mxf_write_ffv1_subdesc(AVFormatContext *s, AVStream *st) · 20 unmodified lines | ||
| 1597 | 1599 | } |
| 1598 | 1600 | |
| 1599 | 1601 | mxf_update_klv_size(s->pb, pos); |
| 1602 | + return 0; | |
| 1600 | 1603 | } |
| 1601 | 1604 | |
| 1602 | −static void mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st) | |
| 1605 | +static int mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st) | |
| 1603 | 1606 | { |
| 1604 | 1607 | int is_rgb, pos; |
| 1605 | 1608 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codecpar->format); |
| @@ -1608,16 +1611,17 @@ static void mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st) · 2 unmodified lines | ||
| 1608 | 1611 | |
| 1609 | 1612 | pos = mxf_write_cdci_common(s, st, is_rgb ? mxf_rgba_descriptor_key : mxf_cdci_descriptor_key); |
| 1610 | 1613 | mxf_update_klv_size(s->pb, pos); |
| 1611 | − mxf_write_ffv1_subdesc(s, st); | |
| 1614 | + return mxf_write_ffv1_subdesc(s, st); | |
| 1612 | 1615 | } |
| 1613 | 1616 | |
| 1614 | −static void mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st) | |
| 1617 | +static int mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st) | |
| 1615 | 1618 | { |
| 1616 | 1619 | int64_t pos = mxf_write_generic_desc(s, st, mxf_s436m_anc_descriptor_key); |
| 1617 | 1620 | mxf_update_klv_size(s->pb, pos); |
| 1621 | + return 0; | |
| 1618 | 1622 | } |
| 1619 | 1623 | |
| 1620 | −static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) | |
| 1624 | +static int mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) | |
| 1621 | 1625 | { |
| 1622 | 1626 | AVIOContext *pb = s->pb; |
| 1623 | 1627 | MXFStreamContext *sc = st->priv_data; |
| @@ -1653,6 +1657,7 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) · 29 unmodified lines | ||
| 1653 | 1657 | } |
| 1654 | 1658 | |
| 1655 | 1659 | mxf_update_klv_size(pb, pos); |
| 1660 | + return 0; | |
| 1656 | 1661 | } |
| 1657 | 1662 | |
| 1658 | 1663 | static int64_t mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, const UID key) |
| @@ -1719,22 +1724,25 @@ static int64_t mxf_write_wav_common(AVFormatContext *s, AVStream *st, const UID · 60 unmodified lines | ||
| 1719 | 1724 | return pos; |
| 1720 | 1725 | } |
| 1721 | 1726 | |
| 1722 | −static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st) | |
| 1727 | +static int mxf_write_wav_desc(AVFormatContext *s, AVStream *st) | |
| 1723 | 1728 | { |
| 1724 | 1729 | int64_t pos = mxf_write_wav_common(s, st, mxf_wav_descriptor_key); |
| 1725 | 1730 | mxf_update_klv_size(s->pb, pos); |
| 1731 | + return 0; | |
| 1726 | 1732 | } |
| 1727 | 1733 | |
| 1728 | −static void mxf_write_aes3_desc(AVFormatContext *s, AVStream *st) | |
| 1734 | +static int mxf_write_aes3_desc(AVFormatContext *s, AVStream *st) | |
| 1729 | 1735 | { |
| 1730 | 1736 | int64_t pos = mxf_write_wav_common(s, st, mxf_aes3_descriptor_key); |
| 1731 | 1737 | mxf_update_klv_size(s->pb, pos); |
| 1738 | + return 0; | |
| 1732 | 1739 | } |
| 1733 | 1740 | |
| 1734 | −static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st) | |
| 1741 | +static int mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st) | |
| 1735 | 1742 | { |
| 1736 | 1743 | int64_t pos = mxf_write_generic_sound_common(s, st, mxf_generic_sound_descriptor_key); |
| 1737 | 1744 | mxf_update_klv_size(s->pb, pos); |
| 1745 | + return 0; | |
| 1738 | 1746 | } |
| 1739 | 1747 | |
| 1740 | 1748 | static const uint8_t mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; |
| @@ -1786,7 +1794,7 @@ static int mxf_write_user_comments(AVFormatContext *s, const AVDictionary *m) · 45 unmodified lines | ||
| 1786 | 1794 | return count; |
| 1787 | 1795 | } |
| 1788 | 1796 | |
| 1789 | −static void mxf_write_package(AVFormatContext *s, MXFPackage *package) | |
| 1797 | +static int mxf_write_package(AVFormatContext *s, MXFPackage *package) | |
| 1790 | 1798 | { |
| 1791 | 1799 | MXFContext *mxf = s->priv_data; |
| 1792 | 1800 | AVIOContext *pb = s->pb; |
| @@ -1881,9 +1889,13 @@ static void mxf_write_package(AVFormatContext *s, MXFPackage *package) · 88 unmodified lines | ||
| 1881 | 1889 | |
| 1882 | 1890 | if (package->type == SourcePackage && package->instance == 1) { |
| 1883 | 1891 | MXFStreamContext *sc = st->priv_data; |
| 1884 | − mxf_essence_container_uls[sc->index].write_desc(s, st); | |
| 1892 | + int ret = mxf_essence_container_uls[sc->index].write_desc(s, st); | |
| 1893 | + if (ret < 0) | |
| 1894 | + return ret; | |
| 1885 | 1895 | } |
| 1886 | 1896 | } |
| 1897 | + | |
| 1898 | + return 0; | |
| 1887 | 1899 | } |
| 1888 | 1900 | |
| 1889 | 1901 | static int mxf_write_essence_container_data(AVFormatContext *s) |
| @@ -1951,8 +1963,11 @@ static int mxf_write_header_metadata_sets(AVFormatContext *s) · 61 unmodified lines | ||
| 1951 | 1963 | mxf_write_identification(s); |
| 1952 | 1964 | mxf_write_content_storage(s, packages, package_count); |
| 1953 | 1965 | mxf->track_instance_count = 0; |
| 1954 | − for (i = 0; i < package_count; i++) | |
| 1955 | − mxf_write_package(s, &packages[i]); | |
| 1966 | + for (i = 0; i < package_count; i++) { | |
| 1967 | + int ret = mxf_write_package(s, &packages[i]); | |
| 1968 | + if (ret < 0) | |
| 1969 | + return ret; | |
| 1970 | + } | |
| 1956 | 1971 | mxf_write_essence_container_data(s); |
| 1957 | 1972 | return 0; |
| 1958 | 1973 | } |