diff mbox

[FFmpeg-devel] Possible incomplete commit "avcodec/nvenc: support RGB input"

Message ID 91a6b04a-4244-0157-3e1b-4ed0e5976ac1@sky.com
State Not Applicable
Headers show

Commit Message

Sven C. Dack Sept. 8, 2016, 11:39 a.m. UTC
Just a guess, but you are using nv_surface->height, which appears to have been 
rounded up to 1088 while the actual size is 1080. The 1088 is then passed on to 
av_image_copy() where it probably tries to read 1920x1088 pixels from the 
source, but the source might not have that much memory and so it segfaults.

If you change it like this:

  }

... then it's again working for me.

Sven




On 08/09/16 11:00, Sven C. Dack wrote:
> Hallo,
>
> ich schicke Dir noch einen weitere Backtrace mit etwas mehr Details:
>
> (gdb) bt
> #0  0x00007f19eb8e3a3e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
> #1  0x0000000000fbc63e in av_image_copy_plane (height=8, bytewidth=7680, 
> src_linesize=<optimized out>, src=0x7f19ea08f000 "", dst_linesize=<optimized 
> out>, dst=<optimized out>) at src/libavutil/imgutils.c:296
> #2  av_image_copy (dst_data=dst_data@entry=0x7ffe7ef4c720, 
> dst_linesizes=dst_linesizes@entry=0x7ffe7ef4c710, 
> src_data=src_data@entry=0x402c340, 
> src_linesizes=src_linesizes@entry=0x402c380, pix_fmt=AV_PIX_FMT_BGR0, width=1920,
>     height=1088) at src/libavutil/imgutils.c:334
> #3  0x0000000000e37321 in nvenc_copy_frame (avctx=0x395af00, 
> nv_surface=0x3dff560, nv_surface=0x3dff560, lock_buffer_params=0x7ffe7ef4c740, 
> lock_buffer_params=0x7ffe7ef4c740, frame=0x402c340) at 
> src/libavcodec/nvenc.c:1312
> #4  nvenc_upload_frame (nvenc_frame=0x3dff560, frame=0x402c340, 
> avctx=0x395af00) at src/libavcodec/nvenc.c:1430
> #5  ff_nvenc_encode_frame (avctx=0x395af00, pkt=0x7ffe7ef4dc90, 
> frame=0x402c340, got_packet=0x7ffe7ef4db4c) at src/libavcodec/nvenc.c:1660
> #6  0x0000000000a8c9c3 in avcodec_encode_video2 (avctx=avctx@entry=0x395af00, 
> avpkt=avpkt@entry=0x7ffe7ef4dc90, frame=frame@entry=0x402c340, 
> got_packet_ptr=got_packet_ptr@entry=0x7ffe7ef4db4c) at 
> src/libavcodec/utils.c:1961
> #7  0x0000000000496448 in do_video_out (s=0x39592c0, ost=ost@entry=0x395ad00, 
> next_picture=next_picture@entry=0x402c340, sync_ipts=<optimized out>, 
> sync_ipts@entry=-7.62939453125e-06) at src/ffmpeg.c:1175
> #8  0x0000000000498d7f in reap_filters (flush=flush@entry=0) at src/ffmpeg.c:1366
> #9  0x000000000049a940 in transcode_step () at src/ffmpeg.c:4117
> #10 transcode () at src/ffmpeg.c:4161
> #11 0x000000000047d11c in main (argc=<optimized out>, argv=0x7ffe7ef4e5d8) at 
> src/ffmpeg.c:4356
>
> ..
>
> #3  0x0000000000e37321 in nvenc_copy_frame (avctx=0x395af00, 
> nv_surface=0x3dff560, nv_surface=0x3dff560, lock_buffer_params=0x7ffe7ef4c740, 
> lock_buffer_params=0x7ffe7ef4c740, frame=0x402c340) at 
> src/libavcodec/nvenc.c:1312
> 1312        av_image_copy(dst_data, dst_linesize,
> (gdb) list
> 1307            return ret;
> 1308
> 1309        if (frame->format == AV_PIX_FMT_YUV420P)
> 1310            FFSWAP(uint8_t*, dst_data[1], dst_data[2]);
> 1311
> 1312        av_image_copy(dst_data, dst_linesize,
> 1313                      (const uint8_t**)frame->data, frame->linesize, 
> frame->format,
> 1314                      nv_surface->width, nv_surface->height);
> 1315
> 1316        return 0;
> (gdb) ins dst_data
> $10 = {0x2049e0000 "\352", <incomplete sequence \352\352>, 0x0, 0x0, 0x0}
> (gdb) ins dst_linesize
> $11 = {7680, 7680, 7680, 7680}
> (gdb) ins frame
> $12 = (const AVFrame *) 0x402c340
> (gdb) ins *frame
> $13 = {data = {0x7f19e98a6000 "\352", <incomplete sequence \352\352>, 0x0, 
> 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, linesize = {7680, 0, 0, 0, 0, 0, 0, 0}, 
> extended_data = 0x402c340, width = 1920, height = 1080, nb_samples = 0, format 
> = 298,
>   key_frame = 1, pict_type = AV_PICTURE_TYPE_NONE, sample_aspect_ratio = {num 
> = 0, den = 1}, pts = 0, pkt_pts = 0, pkt_dts = 0, coded_picture_number = 0, 
> display_picture_number = 0, quality = 0, opaque = 0x0, error = {0, 0, 0, 0, 0, 0,
>     0, 0}, repeat_pict = 0, interlaced_frame = 0, top_field_first = 0, 
> palette_has_changed = 0, reordered_opaque = -9223372036854775808, sample_rate 
> = 0, channel_layout = 0, buf = {0x402b9c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
>   extended_buf = 0x0, nb_extended_buf = 0, side_data = 0x0, nb_side_data = 0, 
> flags = 0, color_range = AVCOL_RANGE_UNSPECIFIED, color_primaries = 
> AVCOL_PRI_UNSPECIFIED, color_trc = AVCOL_TRC_UNSPECIFIED,
>   colorspace = AVCOL_SPC_UNSPECIFIED, chroma_location = 
> AVCHROMA_LOC_UNSPECIFIED, best_effort_timestamp = 0, pkt_pos = -1, 
> pkt_duration = 0, metadata = 0x0, decode_error_flags = 0, channels = 0, 
> pkt_size = 8294400, qscale_table = 0x0,
>   qstride = 0, qscale_type = 0, qp_table_buf = 0x0, hw_frames_ctx = 0x0}
> (gdb) ins nv_surface
> $14 = (NvencSurface *) 0x3dff560
> (gdb) ins *nv_surface
> $15 = {input_surface = 0x3e0c090, in_ref = 0x0, in_map = {version = 0, 
> subResourceIndex = 0, inputResource = 0x0, registeredResource = 0x0, 
> mappedResource = 0x0, mappedBufferFmt = NV_ENC_BUFFER_FORMAT_UNDEFINED, 
> reserved1 = {
>       0 <repeats 251 times>}, reserved2 = {0x0 <repeats 63 times>}}, reg_idx = 
> 0, width = 1920, height = 1088, pitch = 7680, output_surface = 0x3d97f20, 
> format = NV_ENC_BUFFER_FORMAT_ARGB, size = 1048576, lockCount = 1}
>
>
>
> On 08/09/16 10:30, Timo Rothenpieler wrote:
>>>> for fmt in yuv420p nv12 bgr0 rgb0; do
>>>>      ./ffmpeg -f lavfi -i "testsrc=size=1920x1080:duration=10:rate=30"
>>>> -c:v h264_nvenc -global_quality 20 -pix_fmt "$fmt" -y out_"${fmt}".mkv
>>>> done
>>> You feed to nvenc only rgb? what testsrc only supports. Use testsrc2.
>> pix_fmt should make sure it's properly converted, and according to the
>> output, it does:
>>
>>
>> Stream #0:0: Video: h264 (h264_nvenc) (Main) (H264 / 0x34363248),
>> yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 30 fps, 1k
>> tbn, 30 tbc
>>
>> Stream #0:0: Video: h264 (h264_nvenc) (Main) (H264 / 0x34363248), nv12,
>> 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 30 fps, 1k tbn, 30 tbc
>>
>> Stream #0:0: Video: h264 (h264_nvenc) (Main) (H264 / 0x34363248), bgr0,
>> 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 30 fps, 1k tbn, 30 tbc
>>
>> Stream #0:0: Video: h264 (h264_nvenc) (Main) (H264 / 0x34363248), rgb0,
>> 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 30 fps, 1k tbn, 30 tbc
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff mbox

Patch

--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1311,7 +1311,7 @@  static int nvenc_copy_frame(AVCodecContext *avctx, 
NvencSurface *nv_surface,

      av_image_copy(dst_data, dst_linesize,
                    (const uint8_t**)frame->data, frame->linesize, frame->format,
-                  nv_surface->width, nv_surface->height);
+                  avctx->width, avctx->height);

      return 0;