Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
QT_PAIR_RECEIVE
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lenz su
QT_PAIR_RECEIVE
Commits
a4eb142c
Commit
a4eb142c
authored
Jan 04, 2020
by
lenz su
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解码分辨率 帧率 编码格式 打印到excel
parent
0ba2cf40
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
VideoDecode.pro.user
VideoDecode.pro.user
+1
-1
VideoDecoder.cpp
VideoDecoder/src/VideoDecoder/VideoDecoder.cpp
+21
-7
No files found.
VideoDecode.pro.user
View file @
a4eb142c
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.2, 2020-01-04T1
6:33:07
. -->
<!-- Written by QtCreator 4.10.2, 2020-01-04T1
9:56:44
. -->
<qtcreator>
<qtcreator>
<data>
<data>
<variable>
EnvironmentId
</variable>
<variable>
EnvironmentId
</variable>
...
...
VideoDecoder/src/VideoDecoder/VideoDecoder.cpp
View file @
a4eb142c
...
@@ -8,7 +8,10 @@
...
@@ -8,7 +8,10 @@
#include "QDataStream"
#include "QDataStream"
#include "iostream"
#include "iostream"
using
namespace
std
;
using
namespace
std
;
#include <fstream>
#include <string>
#include <QDateTime>
bool
isloged
=
false
;
VideoDecoder
::
VideoDecoder
()
VideoDecoder
::
VideoDecoder
()
{
{
pCodec
=
nullptr
;
pCodec
=
nullptr
;
...
@@ -33,8 +36,8 @@ void VideoDecoder::initWidth(int width, int height)
...
@@ -33,8 +36,8 @@ void VideoDecoder::initWidth(int width, int height)
#else
#else
int
yuvSize
=
av_image_get_buffer_size
(
AV_PIX_FMT_YUV420P
,
pCodecCtx
->
width
,
pCodecCtx
->
height
,
1
);
//按1字节进行内存对齐,得到的内存大小最接近实际大小
int
yuvSize
=
av_image_get_buffer_size
(
AV_PIX_FMT_YUV420P
,
pCodecCtx
->
width
,
pCodecCtx
->
height
,
1
);
//按1字节进行内存对齐,得到的内存大小最接近实际大小
// int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 0); //按0字节进行内存对齐,得到的内存大小是0
// int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 0); //按0字节进行内存对齐,得到的内存大小是0
// int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 4); //按4字节进行内存对齐,得到的内存大小稍微大一些
// int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 4); //按4字节进行内存对齐,得到的内存大小稍微大一些
unsigned
int
numBytes
=
static_cast
<
unsigned
int
>
(
yuvSize
);
unsigned
int
numBytes
=
static_cast
<
unsigned
int
>
(
yuvSize
);
bufferYUV
=
static_cast
<
uint8_t
*>
(
av_malloc
(
numBytes
*
sizeof
(
uint8_t
)));
bufferYUV
=
static_cast
<
uint8_t
*>
(
av_malloc
(
numBytes
*
sizeof
(
uint8_t
)));
...
@@ -350,15 +353,15 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
...
@@ -350,15 +353,15 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
return
0
;
return
0
;
}
}
// while (0 == avcodec_receive_frame(pCodecCtx, pFrame))
// while (0 == avcodec_receive_frame(pCodecCtx, pFrame))
while
(
1
)
while
(
1
)
{
{
int
ret
=
avcodec_receive_frame
(
pCodecCtx
,
pFrame
);
int
ret
=
avcodec_receive_frame
(
pCodecCtx
,
pFrame
);
if
(
ret
!=
0
)
if
(
ret
!=
0
)
{
{
// char buffer[1024] = {0};
// char buffer[1024] = {0};
// av_strerror(ret, buffer, 1024);
// av_strerror(ret, buffer, 1024);
// fprintf(stderr, "avcodec_receive_frame = %d %s\n", ret, buffer);
// fprintf(stderr, "avcodec_receive_frame = %d %s\n", ret, buffer);
break
;
break
;
}
}
...
@@ -382,6 +385,17 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
...
@@ -382,6 +385,17 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
outBuf
=
bufferYUV
;
outBuf
=
bufferYUV
;
outWidth
=
pCodecCtx
->
width
;
outWidth
=
pCodecCtx
->
width
;
outHeight
=
pCodecCtx
->
height
;
outHeight
=
pCodecCtx
->
height
;
if
(
!
isloged
){
ofstream
oFile
;
oFile
.
open
(
"test.csv"
,
ios
::
out
|
ios
::
trunc
);
oFile
<<
"width"
<<
","
<<
"height"
<<
","
<<
"pix_fmt"
<<
","
<<
"fps"
<<
endl
;
oFile
<<
pCodecCtx
->
width
<<
","
<<
pCodecCtx
->
height
<<
","
<<
"AV_PIX_FMT_YUV420P"
<<
","
<<
pCodecCtx
->
time_base
.
den
<<
endl
;
oFile
.
close
();
isloged
=
true
;
}
}
}
av_packet_unref
(
&
pkt
);
av_packet_unref
(
&
pkt
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment