Changeset 65176 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jan 6, 2017 10:17:41 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/VideoRec.cpp
r65175 r65176 63 63 64 64 /** 65 * Structure for keeping specific video recording codec data. 66 */ 67 typedef struct VIDEORECCODEC 68 { 69 union 70 { 71 struct 72 { 73 /** VPX codec context. */ 74 vpx_codec_ctx_t CodecCtx; 75 /** VPX codec configuration. */ 76 vpx_codec_enc_cfg_t Config; 77 /** VPX image context. */ 78 vpx_image_t RawImage; 79 } VPX; 80 }; 81 } VIDEORECCODEC, *PVIDEORECCODEC; 82 83 /** 65 84 * Strucutre for maintaining a video recording stream. 66 85 */ … … 69 88 /** Container context. */ 70 89 WebMWriter *pEBML; 71 /** VPX codec context. */ 72 vpx_codec_ctx_t VpxCodec; 73 /** VPX configuration. */ 74 vpx_codec_enc_cfg_t VpxConfig; 90 /** Codec data. */ 91 VIDEORECCODEC Codec; 75 92 /** Target X resolution (in pixels). */ 76 93 uint32_t uTargetWidth; … … 87 104 /** YUV buffer the encode function fetches the frame from. */ 88 105 uint8_t *pu8YuvBuf; 89 /** VPX image context. */90 vpx_image_t VpxRawImage;91 106 /** Whether video recording is enabled or not. */ 92 107 bool fEnabled; … … 565 580 pStream->pEBML->close(); 566 581 567 vpx_img_free(&pStream-> VpxRawImage);568 vpx_codec_err_t rcv = vpx_codec_destroy(&pStream-> VpxCodec);582 vpx_img_free(&pStream->Codec.VPX.RawImage); 583 vpx_codec_err_t rcv = vpx_codec_destroy(&pStream->Codec.VPX.CodecCtx); 569 584 Assert(rcv == VPX_CODEC_OK); RT_NOREF(rcv); 570 585 … … 628 643 } 629 644 630 vpx_codec_err_t rcv = vpx_codec_enc_config_default(DEFAULTCODEC, &pStream-> VpxConfig, 0);645 vpx_codec_err_t rcv = vpx_codec_enc_config_default(DEFAULTCODEC, &pStream->Codec.VPX.Config, 0); 631 646 if (rcv != VPX_CODEC_OK) 632 647 { … … 668 683 669 684 /* target bitrate in kilobits per second */ 670 pStream-> VpxConfig.rc_target_bitrate = uRate;685 pStream->Codec.VPX.Config.rc_target_bitrate = uRate; 671 686 /* frame width */ 672 pStream-> VpxConfig.g_w = uWidth;687 pStream->Codec.VPX.Config.g_w = uWidth; 673 688 /* frame height */ 674 pStream-> VpxConfig.g_h = uHeight;689 pStream->Codec.VPX.Config.g_h = uHeight; 675 690 /* 1ms per frame */ 676 pStream-> VpxConfig.g_timebase.num = 1;677 pStream-> VpxConfig.g_timebase.den = 1000;691 pStream->Codec.VPX.Config.g_timebase.num = 1; 692 pStream->Codec.VPX.Config.g_timebase.den = 1000; 678 693 /* disable multithreading */ 679 pStream-> VpxConfig.g_threads = 0;694 pStream->Codec.VPX.Config.g_threads = 0; 680 695 681 696 pStream->uDelay = 1000 / uFps; 682 697 683 698 struct vpx_rational arg_framerate = { (int)uFps, 1 }; 684 rc = pStream->pEBML->writeHeader(&pStream-> VpxConfig, &arg_framerate);699 rc = pStream->pEBML->writeHeader(&pStream->Codec.VPX.Config, &arg_framerate); 685 700 AssertRCReturn(rc, rc); 686 701 687 702 /* Initialize codec */ 688 rcv = vpx_codec_enc_init(&pStream-> VpxCodec, DEFAULTCODEC, &pStream->VpxConfig, 0);703 rcv = vpx_codec_enc_init(&pStream->Codec.VPX.CodecCtx, DEFAULTCODEC, &pStream->Codec.VPX.Config, 0); 689 704 if (rcv != VPX_CODEC_OK) 690 705 { … … 693 708 } 694 709 695 if (!vpx_img_alloc(&pStream-> VpxRawImage, VPX_IMG_FMT_I420, uWidth, uHeight, 1))710 if (!vpx_img_alloc(&pStream->Codec.VPX.RawImage, VPX_IMG_FMT_I420, uWidth, uHeight, 1)) 696 711 { 697 712 LogFlow(("Failed to allocate image %dx%d", uWidth, uHeight)); 698 713 return VERR_NO_MEMORY; 699 714 } 700 pStream->pu8YuvBuf = pStream-> VpxRawImage.planes[0];715 pStream->pu8YuvBuf = pStream->Codec.VPX.RawImage.planes[0]; 701 716 702 717 pCtx->fEnabled = true; … … 793 808 /* presentation time stamp */ 794 809 vpx_codec_pts_t pts = pStream->u64TimeStamp; 795 vpx_codec_err_t rcv = vpx_codec_encode(&pStream-> VpxCodec,796 &pStream-> VpxRawImage,810 vpx_codec_err_t rcv = vpx_codec_encode(&pStream->Codec.VPX.CodecCtx, 811 &pStream->Codec.VPX.RawImage, 797 812 pts /* time stamp */, 798 813 pStream->uDelay /* how long to show this frame */, … … 809 824 for (;;) 810 825 { 811 const vpx_codec_cx_pkt_t *pkt = vpx_codec_get_cx_data(&pStream-> VpxCodec, &iter);826 const vpx_codec_cx_pkt_t *pkt = vpx_codec_get_cx_data(&pStream->Codec.VPX.CodecCtx, &iter); 812 827 if (!pkt) 813 828 break; … … 815 830 { 816 831 case VPX_CODEC_CX_FRAME_PKT: 817 rc = pStream->pEBML->writeBlock(&pStream-> VpxConfig, pkt);832 rc = pStream->pEBML->writeBlock(&pStream->Codec.VPX.Config, pkt); 818 833 break; 819 834 default:
Note:
See TracChangeset
for help on using the changeset viewer.