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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
12 deletions
+26
-12
VideoDecode.pro.user
VideoDecode.pro.user
+1
-1
VideoDecoder.cpp
VideoDecoder/src/VideoDecoder/VideoDecoder.cpp
+25
-11
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
)));
...
@@ -345,20 +348,20 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
...
@@ -345,20 +348,20 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
if
(
avcodec_send_packet
(
pCodecCtx
,
&
pkt
)
!=
0
)
if
(
avcodec_send_packet
(
pCodecCtx
,
&
pkt
)
!=
0
)
{
{
fprintf
(
stderr
,
"input AVPacket to decoder failed!
\n
"
);
fprintf
(
stderr
,
"input AVPacket to decoder failed!
\n
"
);
av_packet_unref
(
&
pkt
);
av_packet_unref
(
&
pkt
);
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
;
}
}
...
@@ -375,13 +378,24 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
...
@@ -375,13 +378,24 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
//格式转换 解码之后的数据是yuv420p的 把她转换成 rgb的图像数据
//格式转换 解码之后的数据是yuv420p的 把她转换成 rgb的图像数据
sws_scale
(
img_convert_ctx
,
sws_scale
(
img_convert_ctx
,
(
uint8_t
const
*
const
*
)
pFrame
->
data
,
pFrame
->
linesize
,
(
uint8_t
const
*
const
*
)
pFrame
->
data
,
pFrame
->
linesize
,
0
,
pCodecCtx
->
height
,
0
,
pCodecCtx
->
height
,
pFrameYUV
->
data
,
pFrameYUV
->
linesize
);
pFrameYUV
->
data
,
pFrameYUV
->
linesize
);
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