History

h264_parser: export video format and dimensions

Anton Khirnov committed 11 years ago

Commit 31d20391 parent 5b1d9ce5 files · +58 −1Browse files

Unified · Split

5 files
  1. doc/APIchanges +4 −0
  2. libavcodec/avcodec.h +22 −0
  3. libavcodec/h264_parser.c +29 −0
  4. libavcodec/parser.c +2 −0
  5. libavcodec/version.h +1 −1
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2014-08-09 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162015-xx-xx - xxxxxxx - lavc 56.13
17 Add width, height, coded_width, coded_height and format to
18 AVCodecParserContext.
19
162015-xx-xx - xxxxxxx - lavu 54.9.0202015-xx-xx - xxxxxxx - lavu 54.9.0
17 Add AV_PIX_FMT_QSV for QSV hardware acceleration.21 Add AV_PIX_FMT_QSV for QSV hardware acceleration.
18 22
libavcodec/avcodec.h+22−0
@@ -3883,6 +3883,28 @@ typedef struct AVCodecParserContext { · 3882 unmodified lines
3883 * For example, this corresponds to H.264 PicOrderCnt.3883 * For example, this corresponds to H.264 PicOrderCnt.
3884 */3884 */
3885 int output_picture_number;3885 int output_picture_number;
3886
3887 /**
3888 * Dimensions of the decoded video intended for presentation.
3889 */
3890 int width;
3891 int height;
3892
3893 /**
3894 * Dimensions of the coded video.
3895 */
3896 int coded_width;
3897 int coded_height;
3898
3899 /**
3900 * The format of the coded data, corresponds to enum AVPixelFormat for video
3901 * and for enum AVSampleFormat for audio.
3902 *
3903 * Note that a decoder can have considerable freedom in how exactly it
3904 * decodes the data, so the format reported here might be different from the
3905 * one returned by a decoder.
3906 */
3907 int format;
3886} AVCodecParserContext;3908} AVCodecParserContext;
3887 3909
3888typedef struct AVCodecParser {3910typedef struct AVCodecParser {
libavcodec/h264_parser.c+29−0
@@ -275,6 +275,35 @@ static inline int parse_nal_units(AVCodecParserContext *s, · 274 unmodified lines
275 h->sps = *h->sps_buffers[h->pps.sps_id];275 h->sps = *h->sps_buffers[h->pps.sps_id];
276 h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);276 h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
277 277
278 s->coded_width = 16 * h->sps.mb_width;
279 s->coded_height = 16 * h->sps.mb_height;
280 s->width = s->coded_width - (h->sps.crop_right + h->sps.crop_left);
281 s->height = s->coded_height - (h->sps.crop_top + h->sps.crop_bottom);
282 if (s->width <= 0 || s->height <= 0) {
283 s->width = s->coded_width;
284 s->height = s->coded_height;
285 }
286
287 switch (h->sps.bit_depth_luma) {
288 case 9:
289 if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P9;
290 else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P9;
291 else s->format = AV_PIX_FMT_YUV420P9;
292 break;
293 case 10:
294 if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P10;
295 else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P10;
296 else s->format = AV_PIX_FMT_YUV420P10;
297 break;
298 case 8:
299 if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P;
300 else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P;
301 else s->format = AV_PIX_FMT_YUV420P;
302 break;
303 default:
304 s->format = AV_PIX_FMT_NONE;
305 }
306
278 avctx->profile = ff_h264_get_profile(&h->sps);307 avctx->profile = ff_h264_get_profile(&h->sps);
279 avctx->level = h->sps.level_idc;308 avctx->level = h->sps.level_idc;
280 309
libavcodec/parser.c+2−0
@@ -89,6 +89,8 @@ found: · 88 unmodified lines
89 s->dts_sync_point = INT_MIN;89 s->dts_sync_point = INT_MIN;
90 s->dts_ref_dts_delta = INT_MIN;90 s->dts_ref_dts_delta = INT_MIN;
91 s->pts_dts_delta = INT_MIN;91 s->pts_dts_delta = INT_MIN;
92 s->format = -1;
93
92 return s;94 return s;
93}95}
94 96
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29#include "libavutil/version.h"29#include "libavutil/version.h"
30 30
31#define LIBAVCODEC_VERSION_MAJOR 5631#define LIBAVCODEC_VERSION_MAJOR 56
32#define LIBAVCODEC_VERSION_MINOR 1232#define LIBAVCODEC_VERSION_MINOR 13
33#define LIBAVCODEC_VERSION_MICRO 033#define LIBAVCODEC_VERSION_MICRO 0
34 34
35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t