@@ -149,6 +149,10 @@ extern "C" {
149
149
#define AV_PIX_FMT_GRAY16BE PIX_FMT_GRAY16BE
150
150
#endif
151
151
152
+ #ifndef PKT_FLAG_KEY
153
+ #define PKT_FLAG_KEY AV_PKT_FLAG_KEY
154
+ #endif
155
+
152
156
#if LIBAVUTIL_BUILD >= (LIBAVUTIL_VERSION_MICRO >= 100 \
153
157
? CALC_FFMPEG_VERSION(52 , 38 , 100 ) : CALC_FFMPEG_VERSION(52 , 13 , 0 ))
154
158
#define USE_AV_FRAME_GET_BUFFER 1
@@ -1570,7 +1574,11 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
1570
1574
// some formats want stream headers to be seperate
1571
1575
if (oc->oformat ->flags & AVFMT_GLOBALHEADER)
1572
1576
{
1577
+ #if LIBAVCODEC_BUILD > CALC_FFMPEG_VERSION(56, 35, 0)
1578
+ c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
1579
+ #else
1573
1580
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
1581
+ #endif
1574
1582
}
1575
1583
#endif
1576
1584
@@ -1598,23 +1606,24 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st,
1598
1606
#endif
1599
1607
int ret = OPENCV_NO_FRAMES_WRITTEN_CODE;
1600
1608
1601
- if (oc->oformat ->flags & AVFMT_RAWPICTURE) {
1609
+ #if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
1610
+ if (oc->oformat ->flags & AVFMT_RAWPICTURE)
1611
+ {
1602
1612
/* raw video case. The API will change slightly in the near
1603
1613
futur for that */
1604
1614
AVPacket pkt;
1605
1615
av_init_packet (&pkt);
1606
1616
1607
- #ifndef PKT_FLAG_KEY
1608
- #define PKT_FLAG_KEY AV_PKT_FLAG_KEY
1609
- #endif
1610
-
1611
1617
pkt.flags |= PKT_FLAG_KEY;
1612
1618
pkt.stream_index = video_st->index ;
1613
1619
pkt.data = (uint8_t *)picture;
1614
1620
pkt.size = sizeof (AVPicture);
1615
1621
1616
1622
ret = av_write_frame (oc, &pkt);
1617
- } else {
1623
+ }
1624
+ else
1625
+ #endif
1626
+ {
1618
1627
/* encode the image */
1619
1628
AVPacket pkt;
1620
1629
av_init_packet (&pkt);
@@ -1772,7 +1781,9 @@ void CvVideoWriter_FFMPEG::close()
1772
1781
/* write the trailer, if any */
1773
1782
if (ok && oc)
1774
1783
{
1775
- if ( (oc->oformat ->flags & AVFMT_RAWPICTURE) == 0 )
1784
+ #if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
1785
+ if (!(oc->oformat ->flags & AVFMT_RAWPICTURE))
1786
+ #endif
1776
1787
{
1777
1788
for (;;)
1778
1789
{
@@ -2071,7 +2082,11 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
2071
2082
2072
2083
outbuf = NULL ;
2073
2084
2074
- if (!(oc->oformat ->flags & AVFMT_RAWPICTURE)) {
2085
+
2086
+ #if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
2087
+ if (!(oc->oformat ->flags & AVFMT_RAWPICTURE))
2088
+ #endif
2089
+ {
2075
2090
/* allocate output buffer */
2076
2091
/* assume we will never get codec output with more than 4 bytes per pixel... */
2077
2092
outbuf_size = width*height*4 ;
@@ -2376,7 +2391,11 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
2376
2391
// some formats want stream headers to be seperate
2377
2392
if (oc->oformat ->flags & AVFMT_GLOBALHEADER)
2378
2393
{
2379
- c->flags |= CODEC_FLAG_GLOBAL_HEADER;
2394
+ #if LIBAVCODEC_BUILD > CALC_FFMPEG_VERSION(56, 35, 0)
2395
+ c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
2396
+ #else
2397
+ c->flags |= CODEC_FLAG_GLOBAL_HEADER;
2398
+ #endif
2380
2399
}
2381
2400
#endif
2382
2401
0 commit comments