| 2501 | |
| 2502 | #ifdef NVENC_HAVE_TIME_CODE |
| 2503 | static void nvenc_fill_time_code(AVCodecContext *avctx, const AVFrame *frame, NV_ENC_TIME_CODE *time_code) |
| 2504 | { |
| 2505 | AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_S12M_TIMECODE); |
| 2506 | |
| 2507 | if (sd) { |
| 2508 | uint32_t *tc = (uint32_t*)sd->data; |
| 2509 | int cnt = FFMIN(tc[0], FF_ARRAY_ELEMS(time_code->clockTimestamp)); |
| 2510 | |
| 2511 | switch (cnt) { |
| 2512 | case 0: |
| 2513 | time_code->displayPicStruct = NV_ENC_PIC_STRUCT_DISPLAY_FRAME; |
| 2514 | time_code->skipClockTimestampInsertion = 1; |
| 2515 | break; |
| 2516 | case 2: |
| 2517 | time_code->displayPicStruct = NV_ENC_PIC_STRUCT_DISPLAY_FRAME_DOUBLING; |
| 2518 | break; |
| 2519 | case 3: |
| 2520 | time_code->displayPicStruct = NV_ENC_PIC_STRUCT_DISPLAY_FRAME_TRIPLING; |
| 2521 | break; |
| 2522 | default: |
| 2523 | time_code->displayPicStruct = NV_ENC_PIC_STRUCT_DISPLAY_FRAME; |
| 2524 | break; |
| 2525 | } |
| 2526 | |
| 2527 | for (int i = 0; i < cnt; i++) { |
| 2528 | unsigned hh, mm, ss, ff, drop; |
| 2529 | ff_timecode_set_smpte(&drop, &hh, &mm, &ss, &ff, avctx->framerate, tc[i + 1], 0, 0); |
| 2530 | |
| 2531 | #ifdef NVENC_NEW_COUNTING_TYPE |
| 2532 | time_code->clockTimestamp[i].countingTypeLSB = 0; |
| 2533 | time_code->clockTimestamp[i].countingTypeMSB = 0; |
| 2534 | #else |
| 2535 | time_code->clockTimestamp[i].countingType = 0; |
| 2536 | #endif |
| 2537 | time_code->clockTimestamp[i].discontinuityFlag = 0; |
| 2538 | time_code->clockTimestamp[i].cntDroppedFrames = drop; |
| 2539 | time_code->clockTimestamp[i].nFrames = ff; |
| 2540 | time_code->clockTimestamp[i].secondsValue = ss; |
| 2541 | time_code->clockTimestamp[i].minutesValue = mm; |
| 2542 | time_code->clockTimestamp[i].hoursValue = hh; |
| 2543 | time_code->clockTimestamp[i].timeOffset = 0; |
| 2544 | } |
| 2545 | } else { |
| 2546 | time_code->displayPicStruct = NV_ENC_PIC_STRUCT_DISPLAY_FRAME; |
| 2547 | time_code->skipClockTimestampInsertion = 1; |
| 2548 | } |
| 2549 | } |
| 2550 | #endif |
| 2551 | |
| 2552 | static void nvenc_codec_specific_pic_params(AVCodecContext *avctx, const AVFrame *frame, |
no test coverage detected