Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
67fc8a15
Commit
67fc8a15
authored
10 years ago
by
Vittorio Giovara
Browse files
Options
Downloads
Patches
Plain Diff
theora: support different visible and coded frame size
Signed-off-by:
Vittorio Giovara
<
vittorio.giovara@gmail.com
>
parent
a381e0ce
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/vp3.c
+45
-16
45 additions, 16 deletions
libavcodec/vp3.c
with
45 additions
and
16 deletions
libavcodec/vp3.c
+
45
−
16
View file @
67fc8a15
...
@@ -171,6 +171,8 @@ typedef struct Vp3DecodeContext {
...
@@ -171,6 +171,8 @@ typedef struct Vp3DecodeContext {
Vp3Fragment
*
all_fragments
;
Vp3Fragment
*
all_fragments
;
int
fragment_start
[
3
];
int
fragment_start
[
3
];
int
data_offset
[
3
];
int
data_offset
[
3
];
uint8_t
offset_x
;
uint8_t
offset_y
;
int8_t
(
*
motion_val
[
2
])[
2
];
int8_t
(
*
motion_val
[
2
])[
2
];
...
@@ -1405,14 +1407,14 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
...
@@ -1405,14 +1407,14 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
int
offset
[
AV_NUM_DATA_POINTERS
];
int
offset
[
AV_NUM_DATA_POINTERS
];
if
(
HAVE_THREADS
&&
s
->
avctx
->
active_thread_type
&
FF_THREAD_FRAME
)
{
if
(
HAVE_THREADS
&&
s
->
avctx
->
active_thread_type
&
FF_THREAD_FRAME
)
{
int
y_flipped
=
s
->
flipped_image
?
s
->
avctx
->
height
-
y
:
y
;
int
y_flipped
=
s
->
flipped_image
?
s
->
height
-
y
:
y
;
/* At the end of the frame, report INT_MAX instead of the height of
/* At the end of the frame, report INT_MAX instead of the height of
* the frame. This makes the other threads' ff_thread_await_progress()
* the frame. This makes the other threads' ff_thread_await_progress()
* calls cheaper, because they don't have to clip their values. */
* calls cheaper, because they don't have to clip their values. */
ff_thread_report_progress
(
&
s
->
current_frame
,
ff_thread_report_progress
(
&
s
->
current_frame
,
y_flipped
==
s
->
avctx
->
height
?
INT_MAX
y_flipped
==
s
->
height
?
INT_MAX
:
y_flipped
-
1
,
:
y_flipped
-
1
,
0
);
0
);
}
}
...
@@ -1424,7 +1426,7 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
...
@@ -1424,7 +1426,7 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
y
-=
h
;
y
-=
h
;
if
(
!
s
->
flipped_image
)
if
(
!
s
->
flipped_image
)
y
=
s
->
avctx
->
height
-
y
-
h
;
y
=
s
->
height
-
y
-
h
;
cy
=
y
>>
s
->
chroma_y_shift
;
cy
=
y
>>
s
->
chroma_y_shift
;
offset
[
0
]
=
s
->
current_frame
.
f
->
linesize
[
0
]
*
y
;
offset
[
0
]
=
s
->
current_frame
.
f
->
linesize
[
0
]
*
y
;
...
@@ -1721,8 +1723,8 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
...
@@ -1721,8 +1723,8 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
s
->
version
=
1
;
s
->
version
=
1
;
s
->
avctx
=
avctx
;
s
->
avctx
=
avctx
;
s
->
width
=
FFALIGN
(
avctx
->
width
,
16
);
s
->
width
=
FFALIGN
(
avctx
->
coded_
width
,
16
);
s
->
height
=
FFALIGN
(
avctx
->
height
,
16
);
s
->
height
=
FFALIGN
(
avctx
->
coded_
height
,
16
);
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_NONE
)
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_NONE
)
avctx
->
pix_fmt
=
AV_PIX_FMT_YUV420P
;
avctx
->
pix_fmt
=
AV_PIX_FMT_YUV420P
;
avctx
->
chroma_sample_location
=
AVCHROMA_LOC_CENTER
;
avctx
->
chroma_sample_location
=
AVCHROMA_LOC_CENTER
;
...
@@ -2115,10 +2117,17 @@ static int vp3_decode_frame(AVCodecContext *avctx,
...
@@ -2115,10 +2117,17 @@ static int vp3_decode_frame(AVCodecContext *avctx,
int
row
=
(
s
->
height
>>
(
3
+
(
i
&&
s
->
chroma_y_shift
)))
-
1
;
int
row
=
(
s
->
height
>>
(
3
+
(
i
&&
s
->
chroma_y_shift
)))
-
1
;
apply_loop_filter
(
s
,
i
,
row
,
row
+
1
);
apply_loop_filter
(
s
,
i
,
row
,
row
+
1
);
}
}
vp3_draw_horiz_band
(
s
,
s
->
avctx
->
height
);
vp3_draw_horiz_band
(
s
,
s
->
height
);
/* output frame, offset as needed */
if
((
ret
=
av_frame_ref
(
data
,
s
->
current_frame
.
f
))
<
0
)
if
((
ret
=
av_frame_ref
(
data
,
s
->
current_frame
.
f
))
<
0
)
return
ret
;
return
ret
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
AVFrame
*
dst
=
data
;
int
off
=
(
s
->
offset_x
>>
(
i
&&
s
->
chroma_y_shift
))
+
(
s
->
offset_y
>>
(
i
&&
s
->
chroma_y_shift
))
*
dst
->
linesize
[
i
];
dst
->
data
[
i
]
+=
off
;
}
*
got_frame
=
1
;
*
got_frame
=
1
;
if
(
!
HAVE_THREADS
||
!
(
s
->
avctx
->
active_thread_type
&
FF_THREAD_FRAME
))
{
if
(
!
HAVE_THREADS
||
!
(
s
->
avctx
->
active_thread_type
&
FF_THREAD_FRAME
))
{
...
@@ -2198,7 +2207,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
...
@@ -2198,7 +2207,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
{
{
Vp3DecodeContext
*
s
=
avctx
->
priv_data
;
Vp3DecodeContext
*
s
=
avctx
->
priv_data
;
int
visible_width
,
visible_height
,
colorspace
;
int
visible_width
,
visible_height
,
colorspace
;
int
offset_x
=
0
,
offset_y
=
0
;
u
int
8_t
offset_x
=
0
,
offset_y
=
0
;
int
ret
;
int
ret
;
AVRational
fps
,
aspect
;
AVRational
fps
,
aspect
;
...
@@ -2226,6 +2235,17 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
...
@@ -2226,6 +2235,17 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
offset_y
=
get_bits
(
gb
,
8
);
/* offset y, from bottom */
offset_y
=
get_bits
(
gb
,
8
);
/* offset y, from bottom */
}
}
/* sanity check */
if
(
av_image_check_size
(
visible_width
,
visible_height
,
0
,
avctx
)
<
0
||
visible_width
+
offset_x
>
s
->
width
||
visible_height
+
offset_y
>
s
->
height
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid frame dimensions - w:%d h:%d x:%d y:%d (%dx%d).
\n
"
,
visible_width
,
visible_height
,
offset_x
,
offset_y
,
s
->
width
,
s
->
height
);
return
AVERROR_INVALIDDATA
;
}
fps
.
num
=
get_bits_long
(
gb
,
32
);
fps
.
num
=
get_bits_long
(
gb
,
32
);
fps
.
den
=
get_bits_long
(
gb
,
32
);
fps
.
den
=
get_bits_long
(
gb
,
32
);
if
(
fps
.
num
&&
fps
.
den
)
{
if
(
fps
.
num
&&
fps
.
den
)
{
...
@@ -2259,16 +2279,25 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
...
@@ -2259,16 +2279,25 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
skip_bits
(
gb
,
3
);
/* reserved */
skip_bits
(
gb
,
3
);
/* reserved */
}
}
// align_get_bits(gb);
ret
=
ff_set_dimensions
(
avctx
,
s
->
width
,
s
->
height
);
if
(
visible_width
<=
s
->
width
&&
visible_width
>
s
->
width
-
16
&&
visible_height
<=
s
->
height
&&
visible_height
>
s
->
height
-
16
&&
!
offset_x
&&
(
offset_y
==
s
->
height
-
visible_height
))
ret
=
ff_set_dimensions
(
avctx
,
visible_width
,
visible_height
);
else
ret
=
ff_set_dimensions
(
avctx
,
s
->
width
,
s
->
height
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
if
(
!
(
avctx
->
flags2
&
CODEC_FLAG2_IGNORE_CROP
)
&&
(
visible_width
!=
s
->
width
||
visible_height
!=
s
->
height
))
{
avctx
->
width
=
visible_width
;
avctx
->
height
=
visible_height
;
// translate offsets from theora axis ([0,0] lower left)
// to normal axis ([0,0] upper left)
s
->
offset_x
=
offset_x
;
s
->
offset_y
=
s
->
height
-
visible_height
-
offset_y
;
if
((
s
->
offset_x
&
0x1F
)
&&
!
(
avctx
->
flags
&
CODEC_FLAG_UNALIGNED
))
{
s
->
offset_x
&=
~
0x1F
;
av_log
(
avctx
,
AV_LOG_WARNING
,
"Reducing offset_x from %d to %d"
"chroma samples to preserve alignment.
\n
"
,
offset_x
,
s
->
offset_x
);
}
}
if
(
colorspace
==
1
)
if
(
colorspace
==
1
)
avctx
->
color_primaries
=
AVCOL_PRI_BT470M
;
avctx
->
color_primaries
=
AVCOL_PRI_BT470M
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment