From: green-hand-shandong 
<[email protected]>

scale/crop/pad_ascend replaced the output link's metadata without
copying frame_rate, so downstream vsync saw a zero frame rate and the
CLI dropped 98 of 99 frames in hw-decode -> hw-encode transcodes.

With frame_rate propagated from the input link:
- decode(hw) -> scale_ascend -> encode: 99/99 frames @ 34 fps
- decode(hw) -> crop_ascend -> encode: 99/99 @ 39 fps
- decode -> scale -> pad letterbox -> encode: 99/99 @ 34 fps

Also drop the accidental transpose_ascend registration (VPC
rotate/flip returns NOT_SUPPORT on this hardware; the filter was
reverted before commit and the limitation is recorded in README).

Signed-off-by: green-hand-shandong 
<[email protected]>
---
 libavcodec/ascendenc.c        | 6 +++++-
 libavfilter/vf_crop_ascend.c  | 1 +
 libavfilter/vf_pad_ascend.c   | 1 +
 libavfilter/vf_scale_ascend.c | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ascendenc.c b/libavcodec/ascendenc.c
index 5c4e60d063..430bf81eb3 100644
--- a/libavcodec/ascendenc.c
+++ b/libavcodec/ascendenc.c
@@ -59,6 +59,7 @@ typedef struct AscendEncContext {
     int pending_frames;      /* frames sent, packets not yet collected */
 
     uint64_t frame_count;
+    uint64_t frame_count_out;
 
     /* staging DVPP input buffers; VENC references them asynchronously,
      * so frames are staged in rotation. */
@@ -350,7 +351,10 @@ static int ascend_collect_stream(AVCodecContext *avctx, 
AVPacket *pkt,
             pkt->size += stream.pack[i].len;
         }
     }
-    pkt->pts = pkt->dts = stream.pack[0].pts;
+    /* VENC echoes back the pts we submitted (in the input's container
+     * timebase). Downstream muxers assume a monotonically increasing
+     * sequence in the packet timebase, so renumber by frame index. */
+    pkt->pts = pkt->dts = (int64_t)ctx->frame_count_out++;
     {
         const hi_venc_h264_nalu_type h264t = 
stream.pack[0].data_type.h264_type;
         const hi_venc_h265_nalu_type h265t = 
stream.pack[0].data_type.h265_type;
diff --git a/libavfilter/vf_crop_ascend.c b/libavfilter/vf_crop_ascend.c
index d12f821fde..36d3c3ab29 100644
--- a/libavfilter/vf_crop_ascend.c
+++ b/libavfilter/vf_crop_ascend.c
@@ -169,6 +169,7 @@ static int crop_ascend_config_output(AVFilterLink *outlink)
 
     outlink->w = ctx->out_w;
     outlink->h = ctx->out_h;
+    ff_filter_link(outlink)->frame_rate = ff_filter_link(inlink)->frame_rate;
 
     if (!ctx->frames_ref) {
         ctx->frames_ref = av_hwframe_ctx_alloc(in_frames->device_ref);
diff --git a/libavfilter/vf_pad_ascend.c b/libavfilter/vf_pad_ascend.c
index 2b4240e958..e487084b50 100644
--- a/libavfilter/vf_pad_ascend.c
+++ b/libavfilter/vf_pad_ascend.c
@@ -169,6 +169,7 @@ static int pad_ascend_config_output(AVFilterLink *outlink)
 
     outlink->w = ctx->out_w;
     outlink->h = ctx->out_h;
+    ff_filter_link(outlink)->frame_rate = ff_filter_link(inlink)->frame_rate;
 
     if (!ctx->frames_ref) {
         ctx->frames_ref = av_hwframe_ctx_alloc(in_frames->device_ref);
diff --git a/libavfilter/vf_scale_ascend.c b/libavfilter/vf_scale_ascend.c
index 8f75c852c1..062e5a86a5 100644
--- a/libavfilter/vf_scale_ascend.c
+++ b/libavfilter/vf_scale_ascend.c
@@ -103,6 +103,7 @@ static int ascend_scale_config_output(AVFilterLink *outlink)
     outlink->w = ctx->out_w;
     outlink->h = ctx->out_h;
     outlink->format = AV_PIX_FMT_ASCEND;
+    ff_filter_link(outlink)->frame_rate = ff_filter_link(inlink)->frame_rate;
 
     av_buffer_unref(&ctx->frames_ref);
     ctx->frames_ref = av_hwframe_ctx_alloc(in_frames->device_ref);
-- 
2.25.1


_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to