[FFmpeg-devel] [PATCH] avformat/mpegts: Only add keyframe index entries for keyframe packets

2019-08-31 Thread fumoboy007
From: fumoboy007 

Signed-off-by: fumoboy007 
---
 libavformat/mpegts.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 47d8d5f877..a35ea65875 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -3201,8 +3201,11 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int 
stream_index,
 if (ret < 0)
 return AV_NOPTS_VALUE;
 if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0) {
+int is_keyframe = (pkt.flags & AV_PKT_FLAG_KEY) != 0;
+
 ff_reduce_index(s, pkt.stream_index);
-av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 
0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
+av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 
0, 0, is_keyframe ? AVINDEX_KEYFRAME : 0);
+
 if (pkt.stream_index == stream_index && pkt.pos >= *ppos) {
 int64_t dts = pkt.dts;
 *ppos = pkt.pos;
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avformat/avformat: Introduced `AVInputFormat.read_timestamp2` to fix keyframe seeking for formats that rely on `read_timestamp` for seeking

2019-08-31 Thread fumoboy007
From: fumoboy007 

If the user omits `AVSEEK_FLAG_ANY`, then the result of the seek should be a 
keyframe. `ff_gen_search` did not respect that contract because it had no good 
way to determine whether a timestamp returned by `read_timestamp` was for a 
keyframe packet.

Therefore, we introduce `read_timestamp2`, which adds a new parameter named 
`prefer_keyframe`. This new parameter tells the input format whether to skip 
non-keyframe packets. The parameter is named `prefer_keyframe` instead of 
something like `keyframe_only` because some formats do not distinguish between 
keyframe and non-keyframe packets.

This commit adds the new function and deprecates the old function. Subsequent 
commits will migrate input formats to the new function.

Signed-off-by: fumoboy007 
---
 libavformat/avformat.h |  9 +++
 libavformat/internal.h |  6 +++--
 libavformat/nutdec.c   |  6 ++---
 libavformat/utils.c| 56 +-
 4 files changed, 60 insertions(+), 17 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6eb329f13f..1db548663c 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -741,6 +741,7 @@ typedef struct AVInputFormat {
  * Get the next timestamp in stream[stream_index].time_base units.
  * @return the timestamp or AV_NOPTS_VALUE if an error occurred
  */
+attribute_deprecated
 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
   int64_t *pos, int64_t pos_limit);
 
@@ -781,6 +782,14 @@ typedef struct AVInputFormat {
  * @see avdevice_capabilities_free() for more details.
  */
 int (*free_device_capabilities)(struct AVFormatContext *s, struct 
AVDeviceCapabilitiesQuery *caps);
+
+/**
+ * Get the next timestamp in stream[stream_index].time_base units.
+ * @param prefer_keyframe Whether to skip over non-keyframe packets (if 
possible).
+ * @return the timestamp or AV_NOPTS_VALUE if an error occurred
+ */
+int64_t (*read_timestamp2)(struct AVFormatContext *s, int stream_index,
+   int64_t *pos, int64_t pos_limit, int 
prefer_keyframe);
 } AVInputFormat;
 /**
  * @}
diff --git a/libavformat/internal.h b/libavformat/internal.h
index d6a039c497..a45c538b21 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -443,7 +443,8 @@ int ff_seek_frame_binary(AVFormatContext *s, int 
stream_index,
 void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t 
timestamp);
 
 int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t 
*pos,
-int64_t (*read_timestamp)(struct AVFormatContext *, int , 
int64_t *, int64_t ));
+int64_t (*read_timestamp)(struct AVFormatContext *, int, 
int64_t *, int64_t),
+int64_t (*read_timestamp2)(struct AVFormatContext *, int, 
int64_t *, int64_t, int));
 
 /**
  * Perform a binary search using read_timestamp().
@@ -456,7 +457,8 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index,
   int64_t pos_max, int64_t pos_limit,
   int64_t ts_min, int64_t ts_max,
   int flags, int64_t *ts_ret,
-  int64_t (*read_timestamp)(struct AVFormatContext *, int 
, int64_t *, int64_t ));
+  int64_t (*read_timestamp)(struct AVFormatContext *, int, 
int64_t *, int64_t),
+  int64_t (*read_timestamp2)(struct AVFormatContext *, 
int, int64_t *, int64_t, int));
 
 /**
  * Set the time base and wrapping info for a given stream. This will be used
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 979cb9a031..f28fb2297e 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -653,7 +653,7 @@ static int64_t find_duration(NUTContext *nut, int64_t 
filesize)
 AVFormatContext *s = nut->avf;
 int64_t duration = 0;
 
-ff_find_last_ts(s, -1, , NULL, nut_read_timestamp);
+ff_find_last_ts(s, -1, , NULL, nut_read_timestamp, NULL);
 
 if(duration > 0)
 s->duration_estimation_method = AVFMT_DURATION_FROM_PTS;
@@ -1251,7 +1251,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
 pos = ff_gen_search(s, -1, dummy.ts, next_node[0]->pos,
 next_node[1]->pos, next_node[1]->pos,
 next_node[0]->ts, next_node[1]->ts,
-AVSEEK_FLAG_BACKWARD, , nut_read_timestamp);
+AVSEEK_FLAG_BACKWARD, , nut_read_timestamp, 
NULL);
 if (pos < 0)
 return pos;
 
@@ -1263,7 +1263,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
 pos2 = ff_gen_search(s, -2, dummy.pos, next_node[0]->pos,
  next_node[1]->pos, next_node[1]->pos,
  next_node[0]->back_ptr, 
next_node[1]->back_ptr,
-  

[FFmpeg-devel] [PATCH 2/2] avformat/mpegts: Fixed keyframe seeking by migrating from `read_timestamp` to `read_timestamp2`

2019-08-31 Thread fumoboy007
From: fumoboy007 

Signed-off-by: fumoboy007 
---
 libavformat/mpegts.c  | 46 ++--
 tests/ref/fate/concat-demuxer-simple2-lavf-ts | 70 ++-
 tests/ref/seek/lavf-ts|  6 +-
 3 files changed, 96 insertions(+), 26 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 47d8d5f877..e9fb140775 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -3184,7 +3184,7 @@ static av_unused int64_t mpegts_get_pcr(AVFormatContext 
*s, int stream_index,
 }
 
 static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
-  int64_t *ppos, int64_t pos_limit)
+  int64_t *ppos, int64_t pos_limit, int 
prefer_keyframe)
 {
 MpegTSContext *ts = s->priv_data;
 int64_t pos;
@@ -3200,10 +3200,14 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int 
stream_index,
 ret = av_read_frame(s, );
 if (ret < 0)
 return AV_NOPTS_VALUE;
+
 if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0) {
+int is_keyframe = (pkt.flags & AV_PKT_FLAG_KEY) != 0;
+
 ff_reduce_index(s, pkt.stream_index);
 av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 
0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
-if (pkt.stream_index == stream_index && pkt.pos >= *ppos) {
+
+if (pkt.stream_index == stream_index && pkt.pos >= *ppos && 
(!prefer_keyframe || is_keyframe)) {
 int64_t dts = pkt.dts;
 *ppos = pkt.pos;
 av_packet_unref();
@@ -3271,26 +3275,26 @@ void avpriv_mpegts_parse_close(MpegTSContext *ts)
 }
 
 AVInputFormat ff_mpegts_demuxer = {
-.name   = "mpegts",
-.long_name  = NULL_IF_CONFIG_SMALL("MPEG-TS (MPEG-2 Transport 
Stream)"),
-.priv_data_size = sizeof(MpegTSContext),
-.read_probe = mpegts_probe,
-.read_header= mpegts_read_header,
-.read_packet= mpegts_read_packet,
-.read_close = mpegts_read_close,
-.read_timestamp = mpegts_get_dts,
-.flags  = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
-.priv_class = _class,
+.name= "mpegts",
+.long_name   = NULL_IF_CONFIG_SMALL("MPEG-TS (MPEG-2 Transport 
Stream)"),
+.priv_data_size  = sizeof(MpegTSContext),
+.read_probe  = mpegts_probe,
+.read_header = mpegts_read_header,
+.read_packet = mpegts_read_packet,
+.read_close  = mpegts_read_close,
+.read_timestamp2 = mpegts_get_dts,
+.flags   = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
+.priv_class  = _class,
 };
 
 AVInputFormat ff_mpegtsraw_demuxer = {
-.name   = "mpegtsraw",
-.long_name  = NULL_IF_CONFIG_SMALL("raw MPEG-TS (MPEG-2 Transport 
Stream)"),
-.priv_data_size = sizeof(MpegTSContext),
-.read_header= mpegts_read_header,
-.read_packet= mpegts_raw_read_packet,
-.read_close = mpegts_read_close,
-.read_timestamp = mpegts_get_dts,
-.flags  = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
-.priv_class = _class,
+.name= "mpegtsraw",
+.long_name   = NULL_IF_CONFIG_SMALL("raw MPEG-TS (MPEG-2 Transport 
Stream)"),
+.priv_data_size  = sizeof(MpegTSContext),
+.read_header = mpegts_read_header,
+.read_packet = mpegts_raw_read_packet,
+.read_close  = mpegts_read_close,
+.read_timestamp2 = mpegts_get_dts,
+.flags   = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
+.priv_class  = _class,
 };
diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts 
b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
index 0f03d6e06b..86fdbc733e 100644
--- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
+++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
@@ -180,6 +180,37 @@ 
audio|0|180321|2.003567|180321|2.003567|2351|0.026122|N/A|N/A|209|N/A|K_
 
video|1|174764|1.941822|171164|1.901822|3600|0.04|N/A|N/A|12678|347800|__MPEGTS
 Stream ID
 
 video|1|178364|1.981822|174764|1.941822|3600|0.04|N/A|N/A|24711|361336|K_
+video|1|110782|1.230911|107182|1.190911|3600|0.04|N/A|N/A|24786|181420|K_MPEGTS
 Stream ID
+
+video|1|114382|1.270911|110782|1.230911|3600|0.04|N/A|N/A|17440|206988|__MPEGTS
 Stream ID
+
+video|1|117982|1.310911|114382|1.270911|3600|0.04|N/A|N/A|15019|224848|__MPEGTS
 Stream ID
+
+video|1|121582|1.350911|117982|1.310911|3600|0.04|N/A|N/A|13449|240640|__MPEGTS
 Stream ID
+
+video|1|125182|1.390911|121582|1.350911|3600|0.04|N/A|N/A|12398|254552|__MPEGTS
 Stream ID
+
+video|1|128782|1.430911|125182|1.390911|3600|0.04|N/A|N/A|13455|267336|__MPEGTS
 Stream ID
+
+audio|0|99515|1.105722|99515|1.105722|2351|0.026122|N/A|N/A|209|308508|K_MPEGTS
 Stream ID
+
+audio|0|101866|1.131844|101866|1.131844|2351|0.026122|N/A|N/A|209|N/A|K_
+audio|0|1042

[FFmpeg-devel] [PATCH] avcodec/decode: Fix missing PTS/DTS for decoders like wmapro

2019-07-14 Thread fumoboy007
From: fumoboy007 

Added back comment (deleted in 061a0c14bb5767bca72e3a7227ca400de439ba09) 
explaining that some audio decoders like wmapro may consume partial data 
without returning a frame.

For these cases, `decode_simple_internal` will be called several times before 
the frame is complete. Due to a bug that this commit fixes, the PTS/DTS that 
was set on the first call would be reset to AV_NOPTS_VALUE on the subsequent 
calls.
---
 libavcodec/decode.c | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6c31166ec2..c4722fa09b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -603,16 +603,25 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 if (ret >= pkt->size || ret < 0) {
 av_packet_unref(pkt);
+avci->last_pkt_props->pts = AV_NOPTS_VALUE;
+avci->last_pkt_props->dts = AV_NOPTS_VALUE;
 } else {
 int consumed = ret;
-
 pkt->data+= consumed;
 pkt->size-= consumed;
 avci->last_pkt_props->size -= consumed; // See extract_packet_props() 
comment.
-pkt->pts  = AV_NOPTS_VALUE;
-pkt->dts  = AV_NOPTS_VALUE;
-avci->last_pkt_props->pts = AV_NOPTS_VALUE;
-avci->last_pkt_props->dts = AV_NOPTS_VALUE;
+
+if (got_frame) {
+// TODO: Do the same for video and subtitles before introducing 
decoders of those types
+// that have AV_CODEC_CAP_SUBFRAMES set. (We need a robust way to 
get the duration of a
+// video or subtitle frame before we can do this.)
+if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
+int64_t frame_duration = av_rescale_q(frame->nb_samples,
+  (AVRational){1, 
avctx->sample_rate},
+  avctx->pkt_timebase);
+avci->last_pkt_props->pts += frame_duration;
+}
+}
 }
 
 if (got_frame)
@@ -625,6 +634,10 @@ static int decode_simple_receive_frame(AVCodecContext 
*avctx, AVFrame *frame)
 {
 int ret;
 
+// Some audio decoders may consume partial data without returning
+// a frame (e.g. wmapro). There is no way to make the caller call
+// avcodec_receive_frame() again without returning a frame, so try
+// to decode more in these cases.
 while (!frame->buf[0]) {
 ret = decode_simple_internal(avctx, frame);
 if (ret < 0)
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/mov: Populate packet duration using `stts` atom instead of guessing.

2019-04-30 Thread fumoboy007
Oops. Will fix.

> On Apr 30, 2019, at 10:58 AM, Michael Niedermayer  
> wrote:
> breaks "make fate"
> 
> make: *** [fate-filter-fps-cfr] Error 1
> make: *** [fate-filter-fps-r] Error 1
> make: *** [fate-filter-fps] Error 1
> make: *** [fate-copy-trac236] Error 1
> make: *** [fate-gaplessenc-itunes-to-ipod-aac] Error 1
> make: *** [fate-mov-zombie] Error 1
> make: *** [fate-mov-aac-2048-priming] Error 1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/h263dec: Fixed VA API, VDPAU, and VideoToolbox hardware acceleration due to missing `hw_configs` property.

2019-04-30 Thread fumoboy007
Ah, I see.

> On Apr 29, 2019, at 4:52 PM, Michael Niedermayer  
> wrote:
> 
> On Mon, Apr 29, 2019 at 02:16:53PM -0700, fumoboy...@me.com wrote:
>> Btw, what’s the difference between `h263` and `h263p`?
> 
> Its described probably best with the encoders:
>.name   = "h263p",
>.long_name  = NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 
> version 2"),
> vs.
>.name   = "h263",
>.long_name  = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
> 
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> If you fake or manipulate statistics in a paper in physics you will never
> get a job again.
> If you fake or manipulate statistics in a paper in medicin you will get
> a job for life at the pharma industry.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/mov: Populate packet duration using `stts` atom instead of guessing.

2019-04-29 Thread fumoboy007
Fixes #7855 (“Last subtitle in MP4 is displayed forever”).
---
 libavformat/isom.h |   3 +
 libavformat/mov.c  | 158 +
 2 files changed, 135 insertions(+), 26 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 69452cae8e..b83744ba09 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -162,6 +162,7 @@ typedef struct MOVStreamContext {
 unsigned int chunk_count;
 int64_t *chunk_offsets;
 unsigned int stts_count;
+unsigned int stts_allocated_size;
 MOVStts *stts_data;
 unsigned int ctts_count;
 unsigned int ctts_allocated_size;
@@ -174,6 +175,8 @@ typedef struct MOVStreamContext {
 unsigned *stps_data;  ///< partial sync sample for mpeg-2 open gop
 MOVElst *elst_data;
 unsigned int elst_count;
+int stts_index;
+int stts_sample;
 int ctts_index;
 int ctts_sample;
 unsigned int sample_size; ///< may contain value calculated from stsd or 
value from stsz atom
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d0347b2970..3d5f5f7ab0 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2886,7 +2886,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 {
 AVStream *st;
 MOVStreamContext *sc;
-unsigned int i, entries, alloc_size = 0;
+unsigned int i, entries = 0;
 int64_t duration=0;
 int64_t total_sample_count=0;
 
@@ -2913,7 +2913,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 int sample_duration;
 unsigned int sample_count;
 unsigned int min_entries = FFMIN(FFMAX(i + 1, 1024 * 1024), entries);
-MOVStts *stts_data = av_fast_realloc(sc->stts_data, _size,
+MOVStts *stts_data = av_fast_realloc(sc->stts_data, 
>stts_allocated_size,
  min_entries * 
sizeof(*sc->stts_data));
 if (!stts_data) {
 av_freep(>stts_data);
@@ -3130,11 +3130,15 @@ static int get_edit_list_entry(MOVContext *mov,
 static int find_prev_closest_index(AVStream *st,
AVIndexEntry *e_old,
int nb_old,
+   MOVStts* stts_data,
+   int64_t stts_count,
MOVStts* ctts_data,
int64_t ctts_count,
int64_t timestamp_pts,
int flag,
int64_t* index,
+   int64_t* stts_index,
+   int64_t* stts_sample,
int64_t* ctts_index,
int64_t* ctts_sample)
 {
@@ -3176,6 +3180,15 @@ static int find_prev_closest_index(AVStream *st,
 // Find out the ctts_index for the found frame.
 *ctts_index = 0;
 *ctts_sample = 0;
+
+if (stts_data) {
+av_assert0(stts_index);
+av_assert0(stts_sample);
+
+*stts_index = 0;
+*stts_sample = 0;
+}
+
 for (index_ctts_count = 0; index_ctts_count < *index; 
index_ctts_count++) {
 if (*ctts_index < ctts_count) {
 (*ctts_sample)++;
@@ -3184,6 +3197,13 @@ static int find_prev_closest_index(AVStream *st,
 *ctts_sample = 0;
 }
 }
+if (stts_data && *stts_index < stts_count) {
+(*stts_sample)++;
+if (*stts_sample == stts_data[*stts_index].count) {
+(*stts_index)++;
+*stts_sample = 0;
+}
+}
 }
 
 while (*index >= 0 && (*ctts_index) >= 0 && (*ctts_index) < 
ctts_count) {
@@ -3203,6 +3223,16 @@ static int find_prev_closest_index(AVStream *st,
 } else {
 (*ctts_sample)--;
 }
+if (stts_data) {
+if (*stts_sample == 0) {
+(*stts_index)--;
+if (*stts_index >= 0) {
+*stts_sample = stts_data[*stts_index].count - 1;
+}
+} else {
+(*stts_sample)--;
+}
+}
 }
 }
 
@@ -3275,34 +3305,44 @@ static void fix_index_entry_timestamps(AVStream* st, 
int end_index, int64_t end_
 }
 
 /**
- * Append a new ctts entry to ctts_data.
- * Returns the new ctts_count if successful, else returns -1.
+ * Append a new stts entry to stts_data.
+ * Returns the new stts_count if successful, else returns -1.
  */
-static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, 
unsigned int* allocated_size,
+static int64_t add_stts_entry(MOVStts** stts_data, unsigned int* stts_count, 
unsigned int* allocated_size,
   int count, int duration)
 {
-MOVStts *ctts_buf_new;
-

[FFmpeg-devel] [PATCH] avcodec/decode: Do not output subtitle frames if the packet is marked with `AV_PKT_FLAG_DISCARD`.

2019-04-29 Thread fumoboy007
One situation where a subtitle packet can be marked for discard is when 
demuxing an MOV file that has an edit list.
---
 libavcodec/decode.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6c31166ec2..204bd50fa3 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1149,8 +1149,14 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
AVSubtitle *sub,
 }
 }
 
-if (*got_sub_ptr)
-avctx->frame_number++;
+if (*got_sub_ptr) {
+if (avpkt->flags & AV_PKT_FLAG_DISCARD) {
+*got_sub_ptr = 0;
+avsubtitle_free(sub);
+} else {
+avctx->frame_number++;
+}
+}
 }
 
 return ret;
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/h263dec: Fixed VA API, VDPAU, and VideoToolbox hardware acceleration due to missing `hw_configs` property.

2019-04-29 Thread fumoboy007
Btw, what’s the difference between `h263` and `h263p`?

> On Apr 29, 2019, at 2:12 PM, fumoboy007  wrote:
> 
> Bug originally introduced in commit 758fbc54fef2f31957b5c5f22e05e5fd9b04f631.
> ---
> libavcodec/h263dec.c | 27 +++
> 1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
> index 8385ddfe2e..6f001f6d47 100644
> --- a/libavcodec/h263dec.c
> +++ b/libavcodec/h263dec.c
> @@ -743,6 +743,19 @@ const enum AVPixelFormat 
> ff_h263_hwaccel_pixfmt_list_420[] = {
> AV_PIX_FMT_NONE
> };
> 
> +const AVCodecHWConfigInternal *ff_h263_hw_config_list[] = {
> +#if CONFIG_H263_VAAPI_HWACCEL
> +HWACCEL_VAAPI(h263),
> +#endif
> +#if CONFIG_MPEG4_VDPAU_HWACCEL
> +HWACCEL_VDPAU(mpeg4),
> +#endif
> +#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
> +HWACCEL_VIDEOTOOLBOX(h263),
> +#endif
> +NULL
> +};
> +
> AVCodec ff_h263_decoder = {
> .name   = "h263",
> .long_name  = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / 
> H.263-1998 / H.263 version 2"),
> @@ -758,6 +771,7 @@ AVCodec ff_h263_decoder = {
> .flush  = ff_mpeg_flush,
> .max_lowres = 3,
> .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
> +.hw_configs = ff_h263_hw_config_list,
> };
> 
> AVCodec ff_h263p_decoder = {
> @@ -775,16 +789,5 @@ AVCodec ff_h263p_decoder = {
> .flush  = ff_mpeg_flush,
> .max_lowres = 3,
> .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
> -.hw_configs = (const AVCodecHWConfigInternal*[]) {
> -#if CONFIG_H263_VAAPI_HWACCEL
> -HWACCEL_VAAPI(h263),
> -#endif
> -#if CONFIG_MPEG4_VDPAU_HWACCEL
> -HWACCEL_VDPAU(mpeg4),
> -#endif
> -#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
> -HWACCEL_VIDEOTOOLBOX(h263),
> -#endif
> -NULL
> -},
> +.hw_configs = ff_h263_hw_config_list,
> };
> -- 
> 2.21.0
> 

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/h263dec: Fixed VA API, VDPAU, and VideoToolbox hardware acceleration due to missing `hw_configs` property.

2019-04-29 Thread fumoboy007
Bug originally introduced in commit 758fbc54fef2f31957b5c5f22e05e5fd9b04f631.
---
 libavcodec/h263dec.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8385ddfe2e..6f001f6d47 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -743,6 +743,19 @@ const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] 
= {
 AV_PIX_FMT_NONE
 };
 
+const AVCodecHWConfigInternal *ff_h263_hw_config_list[] = {
+#if CONFIG_H263_VAAPI_HWACCEL
+HWACCEL_VAAPI(h263),
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+HWACCEL_VDPAU(mpeg4),
+#endif
+#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
+HWACCEL_VIDEOTOOLBOX(h263),
+#endif
+NULL
+};
+
 AVCodec ff_h263_decoder = {
 .name   = "h263",
 .long_name  = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / 
H.263-1998 / H.263 version 2"),
@@ -758,6 +771,7 @@ AVCodec ff_h263_decoder = {
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
+.hw_configs = ff_h263_hw_config_list,
 };
 
 AVCodec ff_h263p_decoder = {
@@ -775,16 +789,5 @@ AVCodec ff_h263p_decoder = {
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
-.hw_configs = (const AVCodecHWConfigInternal*[]) {
-#if CONFIG_H263_VAAPI_HWACCEL
-HWACCEL_VAAPI(h263),
-#endif
-#if CONFIG_MPEG4_VDPAU_HWACCEL
-HWACCEL_VDPAU(mpeg4),
-#endif
-#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
-HWACCEL_VIDEOTOOLBOX(h263),
-#endif
-NULL
-},
+.hw_configs = ff_h263_hw_config_list,
 };
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/h263dec: Fixed missing `hw_configs` property

2019-04-28 Thread fumoboy007
---
 libavcodec/h263dec.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8385ddfe2e..6f001f6d47 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -743,6 +743,19 @@ const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] 
= {
 AV_PIX_FMT_NONE
 };
 
+const AVCodecHWConfigInternal *ff_h263_hw_config_list[] = {
+#if CONFIG_H263_VAAPI_HWACCEL
+HWACCEL_VAAPI(h263),
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+HWACCEL_VDPAU(mpeg4),
+#endif
+#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
+HWACCEL_VIDEOTOOLBOX(h263),
+#endif
+NULL
+};
+
 AVCodec ff_h263_decoder = {
 .name   = "h263",
 .long_name  = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / 
H.263-1998 / H.263 version 2"),
@@ -758,6 +771,7 @@ AVCodec ff_h263_decoder = {
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
+.hw_configs = ff_h263_hw_config_list,
 };
 
 AVCodec ff_h263p_decoder = {
@@ -775,16 +789,5 @@ AVCodec ff_h263p_decoder = {
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
-.hw_configs = (const AVCodecHWConfigInternal*[]) {
-#if CONFIG_H263_VAAPI_HWACCEL
-HWACCEL_VAAPI(h263),
-#endif
-#if CONFIG_MPEG4_VDPAU_HWACCEL
-HWACCEL_VDPAU(mpeg4),
-#endif
-#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
-HWACCEL_VIDEOTOOLBOX(h263),
-#endif
-NULL
-},
+.hw_configs = ff_h263_hw_config_list,
 };
-- 
2.17.2 (Apple Git-113)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".