1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
/*
* Functions for filtering ES data ("fast forward") and writing to ES or TS.
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the MPEG TS, PS and ES tools.
*
* The Initial Developer of the Original Code is Amino Communications Ltd.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Amino Communications Ltd, Swavesey, Cambridge UK
*
* ***** END LICENSE BLOCK *****
*/
#ifndef _filter_fns
#define _filter_fns
#include "filter_defns.h"
/*
* Build a new filter context for "stripping" H.262 data
*
* - `fcontext` is the new filter context
* - `h262` is the H.262 stream to read from
* - `all_IP` is true if the software should keep all I and P pictures
*
* Returns 0 if all goes well, 1 if something goes wrong
*/
extern int build_h262_filter_context_strip(h262_filter_context_p *fcontext,
h262_context_p h262,
int all_IP);
/*
* Build a new filter context for "filtering" H.262 data
*
* - `fcontext` is the new filter context
* - `h262` is the H.262 stream to read from
* - `freq` is the desired speed-up, or the frequency at which frames
* should (ideally) be kept
*
* Returns 0 if all goes well, 1 if something goes wrong
*/
extern int build_h262_filter_context(h262_filter_context_p *fcontext,
h262_context_p h262,
int freq);
/*
* Reset an H.262 filter context, ready to start filtering anew.
*/
extern void reset_h262_filter_context(h262_filter_context_p fcontext);
/*
* Free a filter context
*
* NOTE that this does *not* free the H.262 datastructure to which the
* filter context refers.
*
* - `fcontext` is the filter context, which will be freed, and returned
* as NULL.
*/
extern void free_h262_filter_context(h262_filter_context_p *fcontext);
/*
* Build a new filter context for "stripping" ES data
*
* - `fcontext` is the new filter context
* - `access` is the access unit context to read from
* - `allref` is true if the software should keep all reference pictures
* (H.264) or all I and P pictures (H.264)
*
* Returns 0 if all goes well, 1 if something goes wrong
*/
extern int build_h264_filter_context_strip(h264_filter_context_p *fcontext,
access_unit_context_p access,
int allref);
/*
* Build a new filter context for "filtering" ES data
*
* - `fcontext` is the new filter context
* - `access` is the access unit context to read from
* - `freq` is the desired speed-up, or the frequency at which frames
* should (ideally) be kept
*
* Returns 0 if all goes well, 1 if something goes wrong
*/
extern int build_h264_filter_context(h264_filter_context_p *fcontext,
access_unit_context_p access,
int freq);
/*
* Reset an H.264 filter context, ready to start filtering anew.
*/
extern void reset_h264_filter_context(h264_filter_context_p fcontext);
/*
* Free an H.264 filter context
*
* NOTE that this does *not* free the access unit context to which the
* filter context refers.
*
* - `fcontext` is the filter context, which will be freed, and returned
* as NULL.
*/
extern void free_h264_filter_context(h264_filter_context_p *fcontext);
/*
* Retrieve the next I (and/or, if fcontext->allref, P) frame in this H.262 ES.
*
* Any sequence end "pictures" will be ignored.
*
* Note that the ES data being read should be video-only.
*
* - `fcontext` is the information that tells us what to filter and how
* - if `verbose` is true, then extra information will be output
* - if `quiet` is true, then only errors will be reported
*
* - `seq_hdr` is a sequence header, i.e., that used by the next frame to
* output. This will be NULL if the sequence header has not changed since
* the last call of this function.
*
* Note that the caller should *not* free this, and that it will not be
* maintained over calls of this function (i.e., it is a reference to a
* value within the `fcontext` which is altered by this function).
*
* - `frame` is the next frame to output.
*
* Note that it is the caller's responsibility to free this with
* `free_h262_picture()`.
*
* If an error or EOF is returned, this value is undefined.
*
* - `frames_seen` is the number of I and P frames (start code 0)
* found by this call of the function, including the item returned
* if appropriate.
*
* Returns 0 if it succeeds, EOF if end-of-file is read (or the last call
* returned a sequence end item), 1 if some error occurs.
*
* If command input is enabled, then it can also return COMMAND_RETURN_CODE
* if the current command has changed.
*/
extern int get_next_stripped_h262_frame(h262_filter_context_p fcontext,
int verbose,
int quiet,
h262_picture_p *seq_hdr,
h262_picture_p *frame,
int *frames_seen);
/*
* Retrieve the next I frame, from the H.262 ES, aiming for an "apparent" kept
* frequency as stated.
*
* Any sequence end "pictures" will be ignored.
*
* Note that the ES data being read should be video-only.
*
* - `fcontext` is the information that tells us what to filter and how
* (including the desired frequency)
* - if `verbose` is true, then extra information will be output
* - if `quiet` is true, then only errors will be reported
*
* - `seq_hdr` is a sequence header, i.e., that used by the next picture to
* output. This will be NULL if `frame` is NULL.
*
* Note that the caller should *not* free this, and that it will not be
* maintained over calls of this function (i.e., it is a reference to a
* value within the `fcontext` which is altered by this function).
*
* - `frame` is the next frame to output. This will be NULL if the last frame
* should be output again, to provide the requested apparent frequency.
*
* Note that it is the caller's responsibility to free this with
* `free_h262_picture()`.
*
* If an error or EOF is returned, this value is undefined.
*
* - `frames_seen` is the number of I and P frames found by this call of
* the function, including the item returned if appropriate.
*
* Returns 0 if it succeeds, EOF if end-of-file is read, or we've just read a
* sequence end item, or the last call ended a picture on a sequence end
* item, 1 if some error occurs.
*
* If command input is enabled, then it can also return COMMAND_RETURN_CODE
* if the current command has changed.
*/
extern int get_next_filtered_h262_frame(h262_filter_context_p fcontext,
int verbose,
int quiet,
h262_picture_p *seq_hdr,
h262_picture_p *frame,
int *frames_seen);
/*
* Return the next IDR or I (and maybe any reference) frame from this H.264 ES.
*
* Note that the ES data being read should be video-only.
*
* - `fcontext` is the information that tells us what to filter and how
* - if `verbose` is true, then extra information will be output
* - if `quiet` is true, then only errors will be reported
* - `frame` is the next frame to output.
* Note that it is the caller's responsibility to free this with
* `free_access_unit()`.
* If an error or EOF is returned, this value is undefined.
* - `frames_seen` is the number of frames found by this call
* of the function, including the frame returned.
*
* Returns 0 if it succeeds, EOF if end-of-file is read (or an an end of
* stream NAL unit has been passed), 1 if some error occurs.
*
* If command input is enabled, then it can also return COMMAND_RETURN_CODE
* if the current command has changed.
*/
extern int get_next_stripped_h264_frame(h264_filter_context_p fcontext,
int verbose,
int quiet,
access_unit_p *frame,
int *frames_seen);
/*
* Retrieve the next frame from the H.264 (MPEG-4/AVC) ES, aiming
* for an "apparent" kept frequency as stated.
*
* Note that the ES data being read should be video-only.
*
* - `fcontext` is the information that tells us what to filter and how
* (including the desired frequency)
* - if `verbose` is true, then extra information will be output
* - if `quiet` is true, then only errors will be reported
*
* - `frame` is the next frame to output.
*
* If the function succeeds and `frame` is NULL, it means that the
* last frame should be output again.
*
* Note that it is the caller's responsibility to free this frame with
* `free_access_unit()`.
*
* If an error or EOF is returned, this value is undefined.
*
* - `frames_seen` is the number of frames found by this call of the function,
* including the frame returned.
*
* Returns 0 if all went well, 1 if something went wrong.
*
* If command input is enabled, then it can also return COMMAND_RETURN_CODE
* if the current command has changed.
*/
extern int get_next_filtered_h264_frame(h264_filter_context_p fcontext,
int verbose,
int quiet,
access_unit_p *frame,
int *frames_seen);
#endif // _filter_fns
// Local Variables:
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 2
// End:
// vim: set tabstop=8 shiftwidth=2 expandtab:
|