| 24 | #include "get_bits.h" |
| 25 | |
| 26 | int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len, |
| 27 | void **data, size_t *sei_size) |
| 28 | { |
| 29 | AVFrameSideData *side_data = NULL; |
| 30 | uint8_t *sei_data; |
| 31 | |
| 32 | if (frame) |
| 33 | side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC); |
| 34 | |
| 35 | if (!side_data) { |
| 36 | *data = NULL; |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | *sei_size = side_data->size + 11; |
| 41 | *data = av_mallocz(*sei_size + prefix_len); |
| 42 | if (!*data) |
| 43 | return AVERROR(ENOMEM); |
| 44 | sei_data = (uint8_t*)*data + prefix_len; |
| 45 | |
| 46 | // country code |
| 47 | sei_data[0] = 181; |
| 48 | sei_data[1] = 0; |
| 49 | sei_data[2] = 49; |
| 50 | |
| 51 | /** |
| 52 | * 'GA94' is standard in North America for ATSC, but hard coding |
| 53 | * this style may not be the right thing to do -- other formats |
| 54 | * do exist. This information is not available in the side_data |
| 55 | * so we are going with this right now. |
| 56 | */ |
| 57 | AV_WL32(sei_data + 3, MKTAG('G', 'A', '9', '4')); |
| 58 | sei_data[7] = 3; |
| 59 | sei_data[8] = ((side_data->size/3) & 0x1f) | 0x40; |
| 60 | sei_data[9] = 0; |
| 61 | |
| 62 | memcpy(sei_data + 10, side_data->data, side_data->size); |
| 63 | |
| 64 | sei_data[side_data->size+10] = 255; |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | int ff_parse_a53_cc(AVBufferRef **pbuf, const uint8_t *data, int size) |
| 70 | { |
no test coverage detected