Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.protos
Project
Project
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
Linshizhi
ffmpeg.protos
Commits
5afb5e17
Commit
5afb5e17
authored
May 11, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add video validate function to ASSERT streamContextTestCases.
parent
7ae4d203
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
7 deletions
+32
-7
mm.c
src/MovMem/mm.c
+0
-2
utils.c
src/basic/utils.c
+9
-1
utils.h
src/basic/utils.h
+2
-1
streamContextTestCases.c
tests/streamContextTestCases.c
+21
-3
No files found.
src/MovMem/mm.c
View file @
5afb5e17
...
...
@@ -12,8 +12,6 @@ static int mmRead(void *priv, uint8_t *buf, int size) {
MemMovContext
*
context
=
mmc
(
proto
);
List
*
buffers
=
mmpBuffer
(
proto
);
breakPoint
();
if
((
priv
==
NULL
||
buf
==
NULL
||
size
<
0
))
{
return
AVERROR
(
EINVAL
);
}
...
...
src/basic/utils.c
View file @
5afb5e17
#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
void
breakPoint
()
{}
static
char
cmd
[
256
];
_Bool
isVideoValid
(
const
char
*
path
)
{
sprintf
(
cmd
,
"ffmpeg -v error -i %s -f null - 2>./log.txt"
,
path
);
return
system
(
cmd
)
==
0
?
true
:
false
;
}
src/basic/utils.h
View file @
5afb5e17
#include <stdio.h>
#include <stdbool.h>
#ifndef UTILS_H
...
...
@@ -6,6 +7,6 @@
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
void
breakPoint
(
);
_Bool
isVideoValid
(
const
char
*
path
);
#endif
/* UTILS_H */
tests/streamContextTestCases.c
View file @
5afb5e17
#include <stdbool.h>
#include "ctest.h"
#include "streamContext.h"
#include "basic/utils.h"
#include "MovMem/mm.h"
#include <libavcodec/bsf.h>
...
...
@@ -76,6 +77,16 @@ CTEST_DATA(STREAM_CONTEXT_CUSTOM_PROTO) {
AVBSFContext
*
bsCtx
;
};
void
timestampSetup
(
AVPacket
*
pkt
,
AVRational
tb
,
int
framerate
,
int
idx
)
{
int
duration
=
(
1
.
0
/
framerate
)
/
av_q2d
(
tb
);
pkt
->
pts
=
idx
*
duration
;
pkt
->
dts
=
(
idx
-
1
)
*
duration
;
pkt
->
duration
=
duration
;
pkt
->
stream_index
=
0
;
pkt
->
pos
=
-
1
;
}
AVBSFContext
*
prepareDatas
(
StreamContext
*
istream
,
MMProto
*
mmp
)
{
int
ret
=
0
;
...
...
@@ -145,6 +156,9 @@ CTEST_SETUP(STREAM_CONTEXT_CUSTOM_PROTO) {
data
->
ofile
,
(
ProtoInfo
){
NULL
,
NULL
,
NULL
},
AVMEDIA_TYPE_VIDEO
);
ASSERT_NOT_NULL
(
data
->
ostream
);
streamNewStream
(
data
->
ostream
,
streamStream
(
data
->
istream
)
->
codecpar
);
streamWriteHeader
(
data
->
ostream
);
data
->
bsCtx
=
prepareDatas
(
data
->
istream
,
data
->
mmp
);
data
->
istream_custom
=
createInStreamContext
(
NULL
,
...
...
@@ -162,7 +176,7 @@ CTEST_TEARDOWN(STREAM_CONTEXT_CUSTOM_PROTO) {
CTEST2
(
STREAM_CONTEXT_CUSTOM_PROTO
,
READ_FROM_CUSTOM_PROTO
)
{
int
ret
=
0
,
i
=
0
;
int
ret
=
0
;
AVPacket
packet
;
uint8_t
*
mem
;
...
...
@@ -190,15 +204,19 @@ CTEST2(STREAM_CONTEXT_CUSTOM_PROTO, READ_FROM_CUSTOM_PROTO) {
}
mmpPush
(
data
->
mmp
,
NULL
,
0
);
int
i
=
0
;
AVStream
*
ostream
=
streamStream
(
data
->
ostream
);
while
(
true
)
{
ret
=
streamReadFrame
(
data
->
istream_custom
,
&
packet
);
if
(
ret
<
0
)
break
;
++
i
;
timestampSetup
(
&
packet
,
ostream
->
time_base
,
30
,
i
++
)
;
streamWriteFrame
(
data
->
ostream
,
&
packet
);
av_packet_unref
(
&
packet
);
}
ASSERT_EQUAL
(
i
,
300
);
streamWriteTrailer
(
data
->
ostream
);
ASSERT_TRUE
(
isVideoValid
(
data
->
ofile
));
}
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